r - How to Remove any row with "." in it? -
in following example, want remove row "." in row names
data<-matrix(nrow=10,ncol=3,1) rownames(data)<-c("a.1","b.2",letters[3:10])
i have tried grep that:
data[( grepl(".", rownames(data))), ]
but, think there missing here. appreciate thanks
'.'
matches character needs escaping.
data <- matrix(nrow=10, ncol=3,1) rownames(data) <- c("a.1", "b.2", letters[3:10]) data[!grepl('\\.', rownames(data)), ] [,1] [,2] [,3] c 1 1 1 d 1 1 1 e 1 1 1 f 1 1 1 g 1 1 1 h 1 1 1 1 1 1 j 1 1 1
Comments
Post a Comment