[R] problem with subsetting in compating one column with a vector

David Freedman 3.14david at gmail.com
Tue Feb 3 13:10:18 CET 2009


Do you really want to use '==' ?  How about '%in%', as in

findings1<-subset(findings,SUBJECTSID %in% SUBJECTS1$SUBJECTSID,
select=c(SUBJECTSID,ORGNUMRES))

David Freedman



dvkirankumar wrote:
> 
> Hi all,
> I got one problem with    "subset()"    function
> 
> hear i executed:
> 
> findings1<-subset(findings,SUBJECTSID==SUBJECTS1$SUBJECTSID,select=c(SUBJECTSID,ORGNUMRES))
> hear     "SUBJECTS1$SUBJECTSID"     vector contains nearly  "65"  values
> the problem is after comparing and subsetting its not giving
> 
> all the values related to that instead its giving randam values
> 
> and giving warning that:
> 
> 
> 
> Warning message:
> In SUBJECTSID == SUBJECTS1$SUBJECTSID :
>   longer object length is not a multiple of shorter object length
> 
> 
> can any one suggest what I can do to retreave all the related data of
> subset
> and store in one object
> 
> 
> thanks in advance
> 
> regards;
> kiran
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/problem-with-subsetting-in-compating-one-column-with-a-vector-tp21805448p21808625.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list