[R] Odd behaviour of R

From: Hiroto Miyoshi <h_m__at_po.harenet.ne.jp>
Date: Fri 18 Aug 2006 - 18:03:52 EST


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_@po.harenet.ne.jp


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 Aug 18 18:09:24 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 Fri 18 Aug 2006 - 20:19:42 EST.

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