[R] help with if statement

Sarah Goslee sarah.goslee at gmail.com
Wed Nov 21 18:24:20 CET 2012


Use ifelse().

ifelse(A$TIME >= 24, A$TIME + 24, A$TIME)

Please in the future use dput() to provide your data, and explain what
"did not work" means.

Sarah

On Wed, Nov 21, 2012 at 12:05 PM, york8866 <yu_york at hotmail.com> wrote:
> Hi all,
>
> I had a dataset A like:
>
> TIME  DV
> 0  0
> 1   10
> 5    20
> 24  30
> 36   80
> 48  60
> 72 15
>
> I would like to add 24 to those values higher than 24 in the TIME column.
>
> I did the following:
>
> If (A$TIME>=24) {
> A$TIME <- A$TIME+24}
>
> It did not work.  How should I do it?
>
> Thanks,
>
>
>
--
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list