Re: [R] if and

2017-02-28 Thread David L Carlson
This is not a reproducible example. You did not even show us one of the scripts that apparently did work. None of your if() statements contains a logical expression. You should read "An Introduction to R" and probably other tutorials on R. https://cran.r-project.org/doc/manuals/r-release/R-intr

Re: [R] If and apply?

2012-02-03 Thread R. Michael Weylandt
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, wrote: > Hello, > > I'm trying to replace any value within a column where the value is less than > 10% of the median

Re: [R] If and apply?

2012-02-03 Thread David Winsemius
On Feb 3, 2012, at 6:17 PM, brann...@mskcc.org wrote: Hello, I'm trying to replace any value within a column where the value is less than 10% of the median of the column with NA. In other words, if the median of one column is 500, any value in that column that is less than 50 should bec