An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20080314/160c3d8d/attachment.pl
test individual values in rows
4 messages · Iain Gallagher, Gábor Csárdi, Erik Iverson
keep <- apply( DATA, 1, min ) >= 100 DATA <- DATA[ keep, ] See ?apply for more. Gabor
On Fri, Mar 14, 2008 at 01:26:49PM +0000, IAIN GALLAGHER wrote:
Hi list. I have a numerical dataset 22,000 rows deep and 43 columns wide. I would like to remove those rows which contain only values less than 100 (ie if any value in the row is greater than 100 the row stays in the dataset). I am unsure how to test each individual value across the rows and then identify the rows which meet my criteria. Can anyone help? Thank you. Iain [[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.
Csardi Gabor <csardi at rmki.kfki.hu> UNIL DGM
If your data.frame is completely numeric, this is easy. If your data.frame is called df, then do df[apply(df, 1, function(x) !all(x < 100)),] Look at ?apply Best, Erik Iverson
IAIN GALLAGHER wrote:
Hi list. I have a numerical dataset 22,000 rows deep and 43 columns wide. I would like to remove those rows which contain only values less than 100 (ie if any value in the row is greater than 100 the row stays in the dataset). I am unsure how to test each individual value across the rows and then identify the rows which meet my criteria. Can anyone help? Thank you. Iain [[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.
Of course, it might be clearer if instead of !all(x < 100) I had put, any(x > 100)
Erik Iverson wrote:
If your data.frame is completely numeric, this is easy. If your data.frame is called df, then do df[apply(df, 1, function(x) !all(x < 100)),] Look at ?apply Best, Erik Iverson IAIN GALLAGHER wrote:
Hi list. I have a numerical dataset 22,000 rows deep and 43 columns wide. I would like to remove those rows which contain only values less than 100 (ie if any value in the row is greater than 100 the row stays in the dataset). I am unsure how to test each individual value across the rows and then identify the rows which meet my criteria. Can anyone help? Thank you. Iain [[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.
______________________________________________ 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.