Sorry for the question, but I really cannot find the right search terms to find an answer.. I have a data frame with strings in some of the columns. I want to know all the rows where the strings in both columns are equal. How do I do this? Thanks, Bernd [[alternative HTML version deleted]]
Just found out that I am actually dealing with factors:> t3[1,5] == t3[1,3]Error in Ops.factor(t3[1, 5], t3[1, 3]) : level sets of factors are different But the problem remains... how can I compare them? Thanks, Bernd |-----Original Message----- |From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On |Behalf Of Bernd Jagla |Sent: Friday, November 30, 2007 10:25 PM |To: r-help at r-project.org |Subject: [R] compare strings | |Sorry for the question, but I really cannot find the right search terms to |find an answer.. | | | |I have a data frame with strings in some of the columns. | |I want to know all the rows where the strings in both columns are equal. | | | |How do I do this? | | | |Thanks, | | | |Bernd | | | [[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.
It helps writing down these question, you are then getting much closer to an answer... summary(as.integer(t3[,2]) == as.integer(t3[,4]) & as.integer(t3[,3]) =as.integer(t3[,5])) will compare two pairs of column pairs and give a count of flase and true rows... -B |-----Original Message----- |From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On |Behalf Of Bernd Jagla |Sent: Friday, November 30, 2007 10:25 PM |To: r-help at r-project.org |Subject: [R] compare strings | |Sorry for the question, but I really cannot find the right search terms to |find an answer.. | | | |I have a data frame with strings in some of the columns. | |I want to know all the rows where the strings in both columns are equal. | | | |How do I do this? | | | |Thanks, | | | |Bernd | | | [[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.
>From: Bernd Jagla <baj2107 at columbia.edu> >Date: 2007/11/30 Fri PM 09:24:34 CST >To: r-help at r-project.org >Subject: [R] compare stringsbelow assumes that there are only 2 columns in the dataframe or that the string columns are the first two columns ? which(df[,1] == df[,2])>Sorry for the question, but I really cannot find the right search terms to >find an answer.. > > > >I have a data frame with strings in some of the columns. > >I want to know all the rows where the strings in both columns are equal. > > > >How do I do this? > > > >Thanks, > > > >Bernd > > > [[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.