Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Plot a graph without NA's

$
0
0
Apartment_no <- c('1-SV','1-SH','3-SV','3-SH','5-SV','5-SH','7-SV','7-SH')
January <- c('', '', '3','5','9','','15','19')
February <- c('5', '', '3','5','','15','','19')
March <- c('5', '', '3','5','16','15','7','')
April <- c('', '', '3','5','','15','','19')
May <- c('', '8', '3','5','','15','','19')
June <- c('12', '', '','5','','15','','19')
July <- c('5', '', '3','5','','15','','19')
August <- c('51', '', '3','','','15','','19')
September <- c('5', '', '3','5','','15','','19')
October <- c('57', '', '','5','','15','','19')
November <- c('5', '', '','5','','21','','19')
December <- c('', '', '33','5','','15','','19')
Heatmeters <- data.frame(Apartment_no,January,February,March
                         ,April,May,June,July,August,September,August,November,December)
library(tidyverse)
library(dplyr)
library(ggplot2)
Heatmeters%>%select(Apartment_no,January,February,March,April,May,June,July,August,September,August,November,December)  
#>   Apartment_no January February March April May June July August September
#> 1         1-SV                5     5             12    5     51         5
#> 2         1-SH                                8                           
#> 3         3-SV       3        3     3     3   3         3      3         3
#> 4         3-SH       5        5     5     5   5    5    5                5
#> 5         5-SV       9             16                                     
#> 6         5-SH               15    15    15  15   15   15     15        15
#> 7         7-SV      15              7                                     
#> 8         7-SH      19       19          19  19   19   19     19        19
#>   November December
#> 1        5         
#> 2                  
#> 3                33
#> 4        5        5
#> 5                  
#> 6       21       15
#> 7                  
#> 8       19       19

I am given certain apartment no's along with the data for each month. For some of the months the data is not given so there are na's. How to avoid these na's while plotting the data in the graph. PS: Apartment no is a character column however the others are numeric. I tried the following code but it didn't work out: plot(data=na.omit(Heatmeters)as.factor(Apartment_no), January,data=Heatmeters). & is it possible to plot data for all the months in one graph. I actually want only those apartments to appear on the graph which have the data corresponding to any month.


Viewing all articles
Browse latest Browse all 201839

Trending Articles