Re: [R] an apply question

2013-01-19 Thread David Winsemius
On Jan 18, 2013, at 9:17 PM, m p wrote: Hello, It should be easu but I cannot figure out how to use apply function. Unless this is a homework question then using `apply` seems inefficient. I am trying to replace negative values in an array with these values + 24. Would appreciate help. Thank

Re: [R] an apply question

2013-01-18 Thread arun
3 #[5,]   21    0    6    9   16 #[6,]   10    4    6    0    0 #[7,]    7    8   21    0   20 #[8,]   19    7   15   19    5 A.K. - Original Message - From: m p To: r-h...@stat.math.ethz.ch Cc: Sent: Saturday, January 19, 2013 12:17 AM Subject: [R] an apply question Hello, It should be ea

Re: [R] an apply question

2013-01-18 Thread Jorge I Velez
Hi m p, You can use either apply(fhours, 2, function(x) ifelse(x < 0, x + 24, x) or shours <- fhours shours[shours < 0 ] <- shours[shours < 0 ] + 24 shours HTH, Jorge.- On Sat, Jan 19, 2013 at 4:17 PM, m p <> wrote: > Hello, > It should be easu but I cannot figure out how to use apply func

[R] an apply question

2013-01-18 Thread m p
Hello, It should be easu but I cannot figure out how to use apply function. I am trying to replace negative values in an array with these values + 24. Would appreciate help. Thanks, Mark shours <- apply(fhours, function(x){if (x < 0) x <- x+24}) Error in match.fun(FUN) : argument "FUN" is missing,