[R] Assigning entries to categories

LogLord nils.schoof at web.de
Thu Jul 1 10:03:55 CEST 2010


As requested, here is some example data:
a=c("x","y","z")
b=c(1,5,8)
c=c(200010,535388,19929)
data=data.frame(a,b,c)

d=c("cat1","cat2","cat3")
b1=c(1,5,8)
c_start=c(200000,500000,600000)
c_stop=c(201000,550000,700000)
category=data.frame(d,b1,c_start,c_stop)

I want to add a variable into data, which assigns in this case to "x"
"cat1", "y" "cat2" and leaves "z" unassigned. So first it should test if b =
b1 for each row and if this is true it should test if c  >= c_start and <=
c_stop. If this is all true the value of d should be transfered into the new
variable.
-- 
View this message in context: http://r.789695.n4.nabble.com/Assigning-entries-to-categories-tp2272697p2274758.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list