f[rowSums(f<=1)>0,colSums(f<=1)>0]
Judging from your result, you want "less than or equal to 1".
HTH,
Stephan
Crosby, Jacy R schrieb:
How can I delete both rows and columns that do not meet a particular cut off
value.
Example:
d <- rbind(c(0, 1, 6, 4),
+ c(2, 5, 7, 5),
+ c(3, 6, 1, 6),
+ c(4, 4, 4, 4))
f <- as.matrix(d)
f
[,1] [,2] [,3] [,4]
[1,] 0 1 6 4
[2,] 2 5 7 5
[3,] 3 6 1 6
[4,] 4 4 4 4
I would like to delete all rows and columns that do not contain at least one
element with a value less than 1. So I'd end up with:
f
[,1] [,2] [,3]
[1,] 0 1 6
[3,] 3 6 1
Note: 1 is an arbitrary cut-off value.
[[alternative HTML version deleted]]
______________________________________________
R-help@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@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.