I am trying to create a graph with timestamps on the X axis from a csv file and can't get it to work. I've distilled my problem down to the basics as follows. Data file looks like:
"timestamp","A","B","C"
"2015-11-20T17:01:40",10,20,90
"2015-11-20T17:01:50",20,25,80
"2015-11-20T17:01:60",30,30,70
I run the following code:
df=read.csv("/tmp/example.csv")
df$timestamp = strptime(df$timestamp, "%Y-%m-%dT%H:%M:%S")
df # Debug Output
Molten <- melt(df, id.vars= "timestamp")
Molten # Debug Output
...and get the following result...
"df" going in:
timestamp A B C
1 2015-11-20 17:01:40 10 20 90
2 2015-11-20 17:01:50 20 25 80
3 2015-11-20 17:01:60 30 30 70
"Molen" out of "melt:
timestamp variable value
1 2015-11-20 17:01:40 A 10
2 2015-11-20 17:01:50 A 20
3 2015-11-20 17:01:60 A 30
4 <NA> B 20
5 <NA> B 25
6 <NA> B 30
I don't know why those <NA>
s are coming out - and that appears to be what's messing up the graphing. If I remove the strptime
line, the <NA>
s do not happen - which makes me believe it's related to that. Granted, in doing that my assumption is the timestamps are just treated as ordinary strings and not parsed as times.