[R] convert zoo object to "standard" R object so I can plot and output to csv file
Henry
hccoles at lbl.gov
Thu Feb 23 21:06:51 CET 2012
Another simple question - trying to specify xlim in a zoo plot and getting
error
my plot line is
plot(z1,
ylim=c(-100,3000),xlim=c(chron("10/30/2011","00:00:00"),chron("10/30/2011","00:20:00")),type="b",xlab="",ylab="1
Minute Fit",cex.lab=1.3)
Error in substring(paste("0", v$day, sep = ""), first = nchar(paste(v$day)))
:
invalid substring argument(s)
Most of the complete code pasted below.....
fmt<-"%m/%d/%Y %H:%M:%S" # describe the date/time format in the file
tail1<-function(x) tail(x,1)
z<-read.zoo("Cooling-1.txt",FUN=as.chron,format=fmt,sep="\t",header=TRUE,aggregate=tail1)
par(oma=c(6,1,4,2)) # set the outside space boundaries
par(mfrow=c(2,1)) # set the number of graphs (rows,cols) going on one page
# plot the original data
par(mar=c(1.1, 5, .9, 0.5))
plot(z, ylim=c(-100,3000),type="b",xlab="",ylab="Raw
Data",col="red",cex.lab=1.3)
grid(nx=NA,ny=NULL,lwd=.5,lty=1,col="red")
# calculate and plot the 1 minute straight line interpolation
m1 <- times("00:01:00")
g <- seq(trunc(start(z),m1),end(z),by = m1)
z1<-na.approx(z,xout = g)
#plot the 1 minute linear interpolation fit
par(mar=c(1.1, 5, .9, 0.5))
#the following plot line generates the error
plot(z1,
ylim=c(-100,3000),xlim=c(chron("10/30/2011","00:00:00"),chron("10/30/2011","00:20:00")),type="b",xlab="",ylab="1
Minute Fit",cex.lab=1.3)
grid(nx=NA,ny=NULL,lwd=.5,lty=1,col="darkgrey")
--
View this message in context: http://r.789695.n4.nabble.com/convert-zoo-object-to-standard-R-object-so-I-can-plot-and-output-to-csv-file-tp4398302p4415078.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list