jeudi 31 octobre 2019

Nested if else-if function "unexpected error" in R getting

I am trying to select the column "sn_r" from the data set "va" where "va$VACHART==1". If this condition is satisfied then I want to store the value in a new column while calculating it using the formula "85+50*log10(va$sn_r)". If the condition does not satisfy it, then search in a different range value of "sn_r" and store it.

In R. I have tried using the if, else if function but there is an unexpected '}' error in "}"

if(va$VACHART=="1" & va$sn_r>"0.025"){
va$ETDRS_R = 85+50*log10(va$sn_r)
}else if(va$VACHART=="1" & "0.020"< vd$sn_r <="0.025"){
va$ETDRS_R = 5
}else if(va$VACHART=="1" & "0.015"< vd$sn_r <="0.020"){
va$ETDRS_R = 3
}else if(va$VACHART=="1" & "0.005"< vd$sn_r <="0.015"){
va$ETDRS_R = 1
}else {#if(va$VACHART=="1" & "0"< vd$sn_r <="0.005"){
va$ETDRS_R = 0
}

Aucun commentaire:

Enregistrer un commentaire