Hi there, I have a dataframe length.unique.info> length.unique.infoabc 12 345 def 16 550 lmn 6 600 I want those names that fall under the condition (length.unique.info[,2][i] <=5 && length.unique.info[,3][i] >=500) abcder<-length.unique.info[which(length.unique.info[,2][i] <=5 && length.unique.info[,3][i] >= 500),1] will "&&" look for both the condition.It isnt returning names is there anything i am missing.Kindly suggest me the way to do it. Regards Ramya -- View this message in context: http://www.nabble.com/Dataframe-help-tp20343288p20343288.html Sent from the R help mailing list archive at Nabble.com.
Hello - Rajasekaramya wrote:> Hi there, > > I have a dataframe length.unique.info >> length.unique.info > abc 12 345 > def 16 550 > lmn 6 600Is this really the output when you print your data.frame? You may have column names for columns 1, 2, and 3? Is the first column a column of row.names, or not? What does dim(length.unique.info) give? Assuming you have names for columns "1", "2" and "3", named, e.g., X1, X2 and X3 subset(length.unique.info, X2 <= 5 & X3 >= 500, select = c(X1)) I don't know what you're trying to do by indexing with 'i'. And to answer your question about '&', see ?Logic> I want those names that fall under the condition (length.unique.info[,2][i] > <=5 && length.unique.info[,3][i] >=500) > > abcder<-length.unique.info[which(length.unique.info[,2][i] <=5 && > length.unique.info[,3][i] >= 500),1] > > will "&&" look for both the condition.It isnt returning names is there > anything i am missing.Kindly suggest me the way to do it. > > Regards > Ramya > > >
hi there I have a dataframe abc 123 345 abc 345 456 lmn 567 345 hkl 568 535 lmn 096 456 lmn 768 094 i want the uniques of column 1 and there corresponsing column 2 and 3 output abc 123 345 lmn 567 345 hkl 568 535 cbind(DF1[,1],DF1[which(unique(DF1[,1]),c(2,3)]) but didnt work kindly let me know how to go abt it ramya -- View this message in context: http://www.nabble.com/dataframe-help-tp20671461p20671461.html Sent from the R help mailing list archive at Nabble.com.
Rajasekaramya <ramya.victory <at> gmail.com> writes:> > > Hi there, > > I have a dataframe length.unique.info > > length.unique.info > abc 12 345 > def 16 550 > lmn 6 600 > I want those names that fall under the condition (length.unique.info[,2][i] > <=5 && length.unique.info[,3][i] >=500)[...] Hello, late answer, but I just looked in the archive... ...and found your question. Maybe it's too long ago, but as I has some time for and fun with it, here a way how to achieve it: intersect( which(mydf[,2] <=5 ), which( mydf[,3] >= 500)) This will result in integer(0), which means, no matching data found. intersect( which(mydf[,2] <=8 ), which( mydf[,3] >= 500)) would bring you 3 as an answer. This is the index 3, which means third row does match. So, you dont need a loop, which I assume you would like to use, when using i as an index (maybe in the range 1:nrow(length.unique.info). Ciao, Oliver