venkata kirankumar
2009-Jun-05 04:11 UTC
[R] problem with using subset from two different tables
Hi all, I am new to R-project my problem is I tried to get subset from two different tables its giving error but if i m tring for geting results from one table its working actually i have to take values from two tables with applying different conditions on two tables like kk- is an object of one table and fk- is an object of another table here i have to get values from these tables like subset(kk & fk,kk$Rmaxtgavcg > 1.256 & fk$rmaxtgavcg < 3.25,select=c(uniqueid)) my doubt is, that if any thing like this expression is there in R-project or i have to go for two different subsets and then adding those two one after another with checking the common uniqueid's any help is more precious to me Thanks in advance kiran. [[alternative HTML version deleted]]
venkata kirankumar wrote:> Hi all, > > I am new to R-project my problem is I tried to get subset from two different > tables its giving error > but if i m tring for geting results from one table its working > > actually i have to take values from two tables with applying different > conditions on two tables like > > > kk- is an object of one table and > fk- is an object of another table > > here i have to get values from these tables like > > subset(kk & fk,kk$Rmaxtgavcg > 1.256 & fk$rmaxtgavcg < > 3.25,select=c(uniqueid)) > > my doubt is, that if any thing like this expression is there in R-project or > i have to go for two different subsets and then adding those two one after > another with checking the common uniqueid's > >Hi Kiran, I assume that your tables are data frames and have the same first dimension. If not, subsetvector<-kk$Rmaxygavcg > 1.256 & fk$rmaxtgavcg < 3.25 will recycle the shorter of the two logical vectors, which is almost certainly not what you want. If they have the same first dimension, you could then combine the tables and get your result: dupnames<-which(names(fk)%in%names(kk)) subset(cbind(kk,fk[,-dupnames]),subsetvector) Jim