If the matrix in question is named "mymat", then
mymat[apply(mymat,1,function(x)sum(abs(x) <= 1.58) < 2),]
(untested due to a lack of a reproducible example) should give
you a matrix without any rows containing two or more values
with absolute value less than 1.58.
I'm not sure ifelse would be of much use here.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Sat, 26 Feb 2011, hind lazrak wrote:
Hello
The data set I am examining has 7425 observations (rows with unique
identifiers) and 46 samples(columns).
I have been trying to generate a dataset that filters out observations
that are "negligible"
The definition of "negligible" is absolute value less or equal to 1.58.
The rule that I would like to adopt to create a new data is: drop rows
in which 2 or more observations have absolute values <= 1.58.
Since I have unique identifier per row, I have tried to reshape the
data so I could create a new variable using an ifelse statement that
would flag observations <=1.58 but I am not getting anywhere with this
approach
I could not come up with an apply function that counts the number of
observations for which the absolute values are below the cutoff I've
specified.
All observations are numerical and I don't have missing values.
Thank you in advance for the help,
Hind
______________________________________________
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.