warning in function (very basic)

Hello there,

I've been struggling for a while with a quite simple function. I am trying to analyse reaction times and I want to take the logarithm of them. I want to convert all negative values to the number 1 before computing the logarithm.

I guess the problem is something about the brackets- but I have been trying around and now I am just confused. I hope that anyone of you with a bit more experience looks at it and sees the problem right away :slight_smile:

grafik

You don't mention WHAT problem you have with this function.

Your screen print shows that RStudio is not happy with the syntax:
see the two red crosses in lines 280 and 281.
Maybe you need a space immediately after if ?

You say you intend to change times but you don't do this.
I think you meant times = ifelse( .... ?

(df_with_rt <- data.frame(random_times = runif(10,-1,1))) # example data

df_with_rt$clean_times <- ifelse(df_with_rt$random_times<=0,
                                 1,
                                 df_with_rt$random_times)
df_with_rt$logt <- log(df_with_rt$clean_times)
df_with_rt

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.