Skip to content

If and apply?

3 messages · brannona at mskcc.org, David Winsemius, R. Michael Weylandt

#
On Feb 3, 2012, at 6:17 PM, brannona at mskcc.org wrote:

            
You didn't show str(gc2) or show us how it might be built.
You want ifelse() rather than if(). You also will need to look more  
carefully at how 'ifelse' is designed.
That probably indicates that you need to look more carefully at ? 
median because it appears you have at least one NA in each of your   
gc2 columns.
Perhaps the sweep function?
You should read the Posting Guide and learn how to post plain text.


David Winsemius, MD
West Hartford, CT
#
Try this:

apply(gc2, 2, function(x) ifelse(x < 0.1*median(x), NA, x)}

ifelse is the vectorized operation you are probably looking for.

Michael
On Fri, Feb 3, 2012 at 6:17 PM, <brannona at mskcc.org> wrote: