To use %in% to a subset in R -


i have data 'data' in r contains 2 columns data$user_id = 323, 10, 2033, 112,... , data$value= 231, 4321, 90,.. futhermore dim(data)= 41000 2

i have vector u <- c(25,36,38,..) , length(u)=900

i want make subset of 'data' 'user_id' equal vector 'u'. in other words, want user_id's in u , entry in data. in r this

newdata <- subset(data, data$user_id %in% u) 

to make sure have same type can this

newdata <- subset(data, as.numeric(data$user_id) %in% as.numeric(u)) 

when type head(newdata) can see make sense , dim(newdata) = 900 2 want.

but when type newdata printet data strange. how can be?

subset uses non-standard evaluation.

newdata <- subset(data, user_id %in% u) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -