Are you sure Fall.dat is identical on both platforms, and that dt is also? Did you intend to ignore the cases where dt$V2 equals zero?
Try, for example, table(which(dt[,2] == 0)) ## also ==1, ==2, ==3 unique( dt[which(dt[,2] == 0),5] ## also ==1, ==2, ==3 unique( dt$V5 ) adding na.rm=TRUE to mean() Also, try this: tmp <- lapply( split( dt$V5, dt$V2) , mean ) Favg <- unlist(tmp) -Don At 4:57 PM -0400 10/5/06, AgusSusanto wrote: >I obtained error messages when I run these commands in UNIX, but I >obtained correct result when I run these command in WINDOWS. Can >somebody point out the problem and give the solution. Thanks. > > > dt<-read.table(file="Fall.dat") > > dim(dt) >[1] 1941 5 > > table(dt$V2) > 0 1 2 3 >220 989 639 93 > > > > Favg<-as.matrix(c(1:max(dt$V2))) > > > > for(i in 1:max(dt$V2)){Favg[i]<-mean(dt[which(dt[,2] == i),5])} > > Favg > [,1] >[1,] NA >[2,] NA >[3,] NA >Warning messages: >argument is not numeric or logical: returning NA (etc) > >______________________________________________ >R-help@stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.