[R] Problem with plotting against time(hh:mm)

arun smartpink111 at yahoo.com
Tue Sep 24 05:12:34 CEST 2013


Hi,

testing<- read.table(text="0:00,0.88
0:05,
0:20,0.6
0:25,0.14
0:30,0.25
0:35,0.5
0:40,0.25
0:45,0.13",sep=",",header=FALSE,stringsAsFactors=TRUE)

# After reading the file using ?read.csv(), try:
 plot(as.numeric(testing$V1),testing$V2,xaxt="n",xlab="TimeStamp",ylab="IntSollrr")
axis(1,as.numeric(testing$V1),levels(testing$V1))


A.K.


Hi guys, 

I am trying to plot the attached .csv (located in my C:\R 
folder). The .csv has 2 columns, where the first 6 rows are headers and 
look something like this: 

CSV-Export, 
, 
,SENS0700 
,28728 
TimeStamp,IntSolIrr 
hh:mm,W/m^2 
0:00,0.88 
0:05, 
0:20,0.6 
0:25,0.14 
0:30,0.25 
0:35,0.5 
0:40,0.25 
0:45,0.13 

If I were to type this 

> setwd("C:/R") 
> testing=read.csv("testing.csv", skip=6, header = FALSE) 
> plot(testing$V2) 

I get a nice graph 

But when I try to plot the graph against time instead and type this 

> setwd("C:/R") 
> testing=read.csv("testing.csv", skip=6, header = FALSE) 
> plot(testing$V1,testing$V2) 

The time gets all screwed up and are no longer in order. 

Is there a way to solve this? I also tried reading the 
documentation on zoo, but I cannot find how to tell R to treat only the 
first column as time in hh:mm format (I get a warning instead using 
read.zoo) 

Thank you!



More information about the R-help mailing list