[R] "which" command
AgusSusanto
gusanto at gmail.com
Thu Oct 5 22:57:20 CEST 2006
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)
More information about the R-help
mailing list