[R] Odd behaviour of R
Hiroto Miyoshi
h_m_ at po.harenet.ne.jp
Fri Aug 18 10:03:52 CEST 2006
Dear R-users
I need your help. I am agonised by the odd behaviour of R
described below
In the following program, data.frame "work" contains no rows,
when Pb set to 0.3 and 0.7
data<-read.csv("output.csv",header=TRUE)
for(N in c(20,40,80,160,320,640,1280)){
for(Pb in seq(0.1,0.9,0.1)){
work<-data[((data$N==N) & (data$Pb==Pb)),]
print(work)
}
}
That is, when Pb set to 0.3 and 0.7,
print(work) prints out the message "[1] N Pb a
b c d outcomeA outcomeB <0 rows> (or 0-length row.names)"
However, data does exist when Pb is 0.3 or 0.7. And
when line "work<-data[((data$N==N) & (data$Pb==Pb)),]"
is placed outside the "for" loops after Pb is manually set to 0.3,
print(work) successfully prints out the appropriate data.
Namely,
> N<-20
> Pb<-0.3
> work<-data[((data$N==N) & (data$Pb==Pb)),]
> work
N Pb a b c d outcomeA outcomeB
22 20 0.3 6 0 0 14 FALSE FALSE
23 20 0.3 5 1 0 14 FALSE FALSE
24 20 0.3 5 1 1 13 FALSE FALSE
...................................................................
Why is this happen?
I am using R version 2.3.0.
Any help is greatly appreciated.
Thank you.
------------------------
Hiroto Miyoshi
h_m_ at po.harenet.ne.jp
More information about the R-help
mailing list