[R] Error in which()

Muhammad Rahiz muhammad.rahiz at ouce.ox.ac.uk
Thu Jul 8 21:23:24 CEST 2010


Hi all,

I'm trying to filter data into respective numbers. For example, if the 
data ranges from 0 to <0.1, group the data. And so on for the rest of 
the data.
There are inconsistencies in the output. For example, b1[[3]] lumps all 
the 0.2s and 0.3s together while 0.6s are not in the output.

Running the function - table(f1) - shows that each of the 
components/numbers has x number of elements in them. But this is not 
showing in the results of the script.

Can anyone assist?


Thanks,

Muhammad




f1 <- read.table("data.txt")
f1 <- f1[which(is.na(f1)==FALSE),1]


x0 <- seq(0,1,0.1)
x1 <- x0 +0.1

b1 <- c()
for (a in 1:length(x)){
b1[[a]] <- f1[which(f1 >= x0[a] & f1 < x1[a])]
}

-- 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100708/d46b9117/attachment.txt>


More information about the R-help mailing list