0

I want to plot two line charts in R (x = time, y = variable), but I have a very complicated data frame. This is the structure:

'data.frame':   300 obs. of  2 variables:
$ ERMES-test2/00:E0:C7:09:36:AD/ems/sensors: Factor w/ 42 levels 
"0.25","10.5",..: 14 NA 26 NA 35 NA 19 NA 32 NA ...
  ..- attr(*, "names")= chr  "2015-04-25 07:10:00.851" "2015-04-25 07:10:00.375" 
"2015-04-25 07:11:00.851" "2015-04-25 07:11:00.375" ...
 $ ERMES-test2/00:E0:C7:09:5F:44/ems/sensors: Factor w/ 11 levels 
"0.077162295",..: NA 6 NA 1 NA 5 NA 3 NA 2 ...
  ..- attr(*, "names")= chr  "2015-04-25 07:10:00.851" "2015-04-25 07:10:00.375" 
"2015-04-25 07:11:00.851" "2015-04-25 07:11:00.375" ...

Here more information:

structure(list(`ERMES-test2/00:E0:C7:09:36:AD/ems/sensors` = structure(c(1L, 
NA, 2L, NA), .Label = c("14.25", "17.25"), class = "factor"), 
    `ERMES-test2/00:E0:C7:09:5F:44/ems/sensors` = structure(c(NA, 
    2L, NA, 1L), .Label = c("0.077162295", "0.46297377000000006"
    ), class = "factor")), .Names = c("ERMES-test2/00:E0:C7:09:36:AD/ems/sensors", 
"ERMES-test2/00:E0:C7:09:5F:44/ems/sensors"), row.names = c("2015-04-25T07:10:00.851Z", 
"2015-04-25T07:10:00.375Z", "2015-04-25T07:11:00.851Z", "2015-04-25T07:11:00.375Z"
), class = "data.frame")

Thanks in advance!

Michele Della Mea
  • 966
  • 2
  • 16
  • 35
  • 2
    Looks like both the columns are factors. So you may need to convert the second column to numeric and plot. i.e. `dat[,2] <- as.numeric(as.character(dat[,2]))` – akrun Jul 24 '15 at 09:39
  • 1
    Some sample data might help too. If you're looking for a time series, it seems as if your time variable may be a `character` vector at the moment, which could make your plot misrepresentation. – Akhil Nair Jul 24 '15 at 10:20
  • Could you provide some sample data? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Mhairi McNeill Jul 24 '15 at 10:23
  • I was looking at the code and I had the same observation of @AkhilNair. Moreover, you seem to need two line charts, but you only have 2 variables... I may be wrong, but it seems like you have both values and times in the same variable. – MaZe Jul 24 '15 at 10:24

0 Answers0