[R] Error Message using xyplot of lattice

arun smartpink111 at yahoo.com
Sun Apr 6 08:14:40 CEST 2014

You didn't provide a reproducible example.  If your dataset is something like this:
DataSeries <- data.frame(Date=seq(as.Date("2001-01-01"),by="1 day", length.out=20), A= sample(10,20,replace=TRUE), B= rnorm(20))

###Using your codes:

Matrix_New1 <- cbind(as.list(DataSeries[,"Date"]),as.list(DataSeries[,"A"]),colnames(DataSeries)[2])

Matrix_New2 <- cbind(as.list(DataSeries[,"Date"]),as.list(DataSeries[,"B"]),colnames(DataSeries)[3])

#List of 60

#List of 60 

Matrix_Complete<- rbind(Matrix_New1,Matrix_New2)
#List of 120
Col_Names_MC<-c("X","Y", "Z")


Plot_AB<-xyplot(Y~ X, data =Matrix_Complete, type =c("l"), groups=Z, as.table=TRUE, main="Development over time")
#Error in eval(expr, envir, enclos) : object 'Z' not found 

#You could try:
 DataSeriesM <- setNames(melt(DataSeries,id.var="Date"),LETTERS[c(24,26,25)])
 xyplot(Y~X,data=DataSeriesM,type="l",groups=Z,as.table=TRUE,main="Development over time")
 #for a numeric X axis
 xyplot(Y~as.numeric(X),data=DataSeriesM,type="l",groups=Z,as.table=TRUE,main="Development over time") 
# with legends
 xyplot(Y~as.numeric(X),xlab="X",data=DataSeriesM,type="l",groups=Z,as.table=TRUE,main="Development over time",auto.key=list(x=.85, y=.95, border=TRUE,lines=TRUE)) 

Hope it helps.


Hi everbody, I have the following error message occuring when I run my code:
"Error in eval(expr, envir, enclos) : object 'Series' not found" The code I am using is the following: Matrix_New1 <- cbind(as.list(DataSeries[,"Date"]),as.list(DataSeries[,"A"]),colnames(DataSeries)[2] )
Matrix_New2 <- cbind(as.list(DataSeries[,"Date"]),as.list(DataSeries[,"B"]),colnames(DataSeries)[3] ) #whereas first and second columns should be numbers, third column is "A" and "B" respectively Matrix_Complete<- rbind(Matrix_New1,Matrix_New2) Col_Names_MC<-c("X","Y", "Z")
colnames(Matrix_Complete)<-Col_Names_MC Plot_AB<-xyplot(Y~ X, data =Matrix_Complete, type =c("l"), groups=Z, as.table=TRUE, main="Development over time") print(Plot_AB) Can you explain me why this way of creating a plot is not working and what I Need to Change in order to be able to plot it? 

More information about the R-help mailing list