venkata kirankumar
2009-Feb-03 08:11 UTC
[R] problem with subsetting in compating one column with a vector
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]]
Petr PIKAL
2009-Feb-03 09:31 UTC
[R] Odp: problem with subsetting in compating one column with a vector
Hi r-help-bounces at r-project.org napsal dne 03.02.2009 09:11:52:> Hi all, > I got one problem with "subset()" function > > hear i executed: > > findings1<-subset(findings,SUBJECTSID==SUBJECTS1$SUBJECTSID,select=c+ (SUBJECTSID,ORGNUMRES)) Error in subset(findings, SUBJECTSID == SUBJECTS1$SUBJECTSID, select = c(SUBJECTSID, : object "findings" not found Gives me an error. Strange, is it possible that I do not have SUBJECTS1 or SUBJECTSID on my computer? however subset(iris, subset=iris$Species=="virginica", select=c("Sepal.Length", "Petal.Length")) Sepal.Length Petal.Length 101 6.3 6.0 102 5.8 5.1 103 7.1 5.9 104 6.3 5.6 105 6.5 5.8 106 7.6 6.6 works as expected Or you can use iris[iris$Species=="virginica", c(1,3)] to get same result without using subset. Regards Petr> 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 ofsubset> 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 guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
David Freedman
2009-Feb-03 12:10 UTC
[R] problem with subsetting in compating one column with a vector
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.