Extract specific rows from a data frame
Hi, May be this helps: df1<- read.table(text=" ? t1 t2 t3 t4 ? len1 AA AA PP AP ? len2 FALSE AA PP MM ? len3 PP AA AA AP ? len4 PP AM MP PP ? len5 AA FALSE AP PP ? len6 PP AA AA AA ",sep="",header=TRUE,stringsAsFactors=FALSE) df1[df1[,1]=="PP" & (rowSums(df1[,-1]!="PP")==(ncol(df1)-1)),] #???? t1 t2 t3 t4 #len3 PP AA AA AP #len6 PP AA AA AA A.K. ----- Original Message ----- From: Chirag Gupta <cxg040 at email.uark.edu> To: r-help at r-project.org Cc: Sent: Saturday, July 20, 2013 6:56 PM Subject: [R] Extract specific rows from a data frame Hi I have a data frame as below ? t1 t1 t3 t4? len1 AA AA PP AP? len2 FALSE AA PP MM? len3 PP AA AA AP? len4 PP AM MP PP? len5 AA FALSE AP PP? len6 PP AA AA AA I am having trouble extracting only those rows which have "PP" in the first column but AA or FALSE or all any other value but not PP in rest of the columns.
*Chirag Gupta* ??? [[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.