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 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, with no default
>
>         [[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.
>

	[[alternative HTML version deleted]]

