Skip to content
Prev 172798 / 398506 Next

Odp: nice way to find or not a value (problem with numeric(0))

Hi

r-help-bounces at r-project.org napsal dne 05.03.2009 15:21:22:
numerical
for
are
write
Not much. Guess what I get using your code? If you think it is 12.5 you 
are mistaken.
code data1
1    4  12.5
2    8  20.2
specmodules$Code)
Error in inherits(x, "factor") : object "specmodules" not found
This is why you shall provide reproducible code. Now I still need to only 
**think** what you want to do.

Maybe merge is what you want

Having spec like above and

test<-data.frame(code = c(4,5,8,12), value= c(10, 20, 30,40))

then

merge(test, spec, by="code", all.x=T)
  code value data1
1    4    10  12.5
2    5    20    NA
3    8    30  20.2
4   12    40    NA

Gives you new data frame which you can then filter by is.na and which to 
replace NA values with standard ones.

Regards
Petr
would
numeric(0)
it
(We
sensible
example
shall
http://www.nabble.com/nice-way-to-find-or-not-a-
http://www.R-project.org/posting-guide.html