Hi R-helpers,

I've been struggling with a problem for most of the day (!) so am finally
resorting to R-help.

I would like to subset the columns of my dataframe based on the frequency
with which the columns contain non-zero values. For example, let's say that
I want to retain only those columns which contain non-zero values in at
least 1% of their rows.

In Excel I would calculate a row at the bottom of my data sheet and use the
following function

=countif(range,">0")

to identify the number of non-zero cells in each column. Then, I would
divide that by the number of rows to obtain the frequency of non-zero values
in each column. Then, I would delete those columns with frequencies < 0.01.

But, I'd like to do this in R. I think the missing link is an analog to
Excel's countif function. Any ideas?

Thanks! Mark

        [[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.

Reply via email to