Dear R-Help,

I have a data frame and a vector

df=data.frame(Letter=c("Z","Q","R","A","E","F"), Number=c(11,32,4,1,9,3))
v=c("C","Q","R","A","E")

>From df, I'd like to construct a subset of the field "Number", with
deletions dictated by the vector, v, of letters.  I've succeeded in doing
this for a single deletion (for example Letter="Q") with the following

df$Number[df$Letter != v[2]]

but am struggling do more than one at a time.  For example, 

df$Number[df$Letter != v[2:5]] 

gives the error:   Warning messages: 1: Is.na(e1) | is.na(e2) : longer
object length is not a multiple of shorter object length 2: In.....  Perhaps
there is a much easier way to approach this...

Any help would be greatly appreciated!

Alastair
-- 
View this message in context: 
http://www.nabble.com/Selecting-vector-elements-using-other-vectors-tp23296130p23296130.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org 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.

Reply via email to