Jurica Seva
2011-Jan-04 22:43 UTC
[R] Error in M[, 1] : incorrect number of dimensions when trying to plot hexbin
Hello again, I am trying to plot out activity regions the user did on the screen via plotting a hexbin. I have 20 users whose information i want to plot out and it stops in the user 16 with the message Error in M[, 1] : incorrect number of dimensions. Any advice would be appreciated as i dont see why this error occurs on the data for the 16th user. All the other users get plotted out without a problem. I am using the R 2.12.1 on W7 if needed. The user data is in the csv file attached to this mail. The R code is: #libraries library(RMySQL) library(hexbin) #user data mycon <- dbConnect(MySQL(), user='root',dbname='test',host='localhost',password='') rsUser01 <- dbSendQuery(mycon, "select a.userID,a.sessionID,a.actionTaken,a.timelineMSEC,a.durationMSEC,b.X,b.Y,b.Rel__dist_,b.Total_dist_ from `actiontimes` as a , `ulogdata` as b where a.originalRECNO = b.RECNO") user01 <- fetch(rsUser01, n= -1) user01[1,1] #list of users mycon <- dbConnect(MySQL(), user='root',dbname='test',host='localhost',password='') listUser <- dbSendQuery(mycon, "select distinct userID from ulogdata") userList <- fetch(listUser, n= -1) par(mfrow=c(5,3)) tmp6=rep("UserScatterActionRegion.pdf") tmp7=paste(tmp6,sep="") tmp7 #pdf(tmp7) jpeg(file="UserScatterActionRegion.jpeg") for (i in 1:20){ x<-subset(user01 ,userID == userList[i,],select=c(X,Y)) x bin<-hexbin(x$X, x$Y, xbins=100) part1=rep("Action Regions") nameFull=paste(userList[i,],part1,sep="") nameFull plot(bin, main=nameFull) } dev.off()