Re: [R] if and

2017-02-28 Thread David L Carlson
7840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Val Sent: Monday, February 27, 2017 7:48 PM To: R help Subject: [R] if and Currently I have about six or more scripts that do the same job. I thought it might be possible and more efficient to

[R] if and

2017-02-27 Thread Val
Currently I have about six or more scripts that do the same job. I thought it might be possible and more efficient to use one script by using IF ELSE statements. Here is an example but this will be expandable for several countries ans year-months Year-month = FEB2015, FEB2012, Feb2010 count

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

[R] If and apply?

2012-02-03 Thread brannona
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 become NA. Doing a lot of searches, it seems like I should be us