[R] Deleting specific rows from a dataframe
arun
smartpink111 at yahoo.com
Tue Jul 16 03:23:51 CEST 2013
Hi,
If I understand it correctly,
df1<- read.table(text="
sample1 sample2 sample3 sample4 sample5
a P P I P P
b P A P P A
c P P P P P
d P P P P P
e M P M A P
f P P P P P
g P P P A P
h P P P P P
",sep="",header=TRUE,stringsAsFactors=FALSE)
df1[rowSums(df1=="P")==ncol(df1),]
# sample1 sample2 sample3 sample4 sample5
#c P P P P P
#d P P P P P
#f P P P P P
#h P P P P P
A.K.
----- Original Message -----
From: Chirag Gupta <cxg040 at email.uark.edu>
To: r-help at r-project.org
Cc:
Sent: Monday, July 15, 2013 9:10 PM
Subject: [R] Deleting specific rows from a dataframe
I have a data frame like shown below
sample1 sample2 sample3 sample4 sample5 a P P I P P b P A P P A c P P P
P P d P P P P P e M P M A P f P P P P P g P P P A P h P P P P P
I want to keep only those rows which have all "P" across all the columns.
Since the matrix is large (about 20,000 rows), I cannot do it in excel
Any special function that i can use?
--
*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.
More information about the R-help
mailing list