plot.window error in loop for R creating basic plots
I apologize for not generating pseudo data for this question, but I think
the problems I am facing are basic to most non novice individuals on this
site. I am attempting to create a loop that plots a scatterplot of x and y
for each value of a z variable.
x=rnorm(n=50)
y=rnorm(n=50)
z<-rep(c(1,2,3,4,5),10)
dataset <-cbind(x,y,z)
Dataset<-as.data.frame(dataset)
attach(Dataset)
jpeg()
z <-Dataset$z[1:5]
for(i in 1:5) {
y<-y[z==i]
x <-x[z==i]
ARMAXpath<-file.path("C:", "Desktop", paste("myplot_", z[i], ".jpg", sep=""))
jpeg(file = ARMAXpath)
TheTitle = paste("Scatter Plots", z[i])
plot.new()
plot.window(xlim=c(0,1), ylim=c(5,10))
plot(y,x)
dev.off()}
detach(Dataset)
No matter what I do I get the same plot.window error. I ran this code with
and without attach. I ran it with and without plot window. I also moved
plot window in ad outside the loop.
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
My question is how do I generate plots of two time series by a third
variable in my dataset (i.e. region) write the output to a file folder as
I have porrly attempted to do above?
Thanks for any help at all
No comments:
Post a Comment