I'm trying to create a function that assigns a new value to previously created values for a formula I am trying to create. The vector I am using is a z-score and then I am trying to assign "points" to each z-score to add to the rest of my formula.
I have struggled first with pulling in a previous vector to use in the function as the only argument, and am now continuously getting errors due to the list of if & else if statements I have created. Any help on how to perfect this, not get errors, and have the correct script would be appreciated!!
** note: I have tried else if, else, and ifelse statements all for the list and I still get errors.**
#this is the z-score calculation for wellness#
wellness_z <- ((wellness_sum- alltime_wellness_sum)/ sd_wellness)
wellness_score <- function(wellness_z)
if (wellness_z==0 )
return(1)
if (wellness_z>=0.01 && wellness_z<=0.49)
return(2)
if (wellness_z>=0.50 && wellness_z<=0.99)
return(3)
if (wellness_z>=1.00 && wellness_z<=1.49)
return(4)
if (wellness_z>=1.50 && wellness_z<=1.99)
return(5)
if (wellness_z>=2.00 && wellness_z<=2.49)
return(6)
if (wellness_z>=2.50 && wellness_z<=2.99)
return(7)
if (wellness_z<=-0.01 && wellness_z>=-0.49)
return(-2)
if (wellness_z<=-0.50 && wellness_z>=-0.99)
return(-3)
if (wellness_z<=-1.00 && wellness_z>=-1.49)
return(-4)
if (wellness_z<=-1.50 && wellness_z>=-1.99)
return(-5)
if (wellness_z<=-2.00 && wellness_z>=-2.49)
return(-6)
if (wellness_z<=-2.50 && wellness_z>=-2.99)
return(-7)