Skip to content
Prev 310994 / 398506 Next

Deleting rows with special character

Hi Peter,
On Fri, Nov 16, 2012 at 9:04 AM, Peter Kupfer <peter.kupfer at me.com> wrote:
A reproducible example with sample data is helpful.
Really? Why not just make a new matrix with the right number of "A" values?
Of course there is. Here's one option. But I'm not sure you've really
stated your actual problem. This extracts the rows where all values
are "A", and might at least get you started toward your real problem.

testdata <- matrix(c(
"A", "B", "C",
"B", "B", "B",
"C", "A", "A",
"A", "A", "A"),
ncol=3, byrow=TRUE)

testdata.A <- testdata[apply(testdata, 1, function(x)all(x == "A")), ,
drop=FALSE]



--
Sarah Goslee
http://www.functionaldiversity.org