[R] "which" command

From: AgusSusanto <gusanto_at_gmail.com>
Date: Thu 05 Oct 2006 - 20:57:20 GMT


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. Received on Fri Oct 06 07:21:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 05 Oct 2006 - 23:30:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.