jeudi 27 septembre 2018

If/else statement syntax using R

I have a semantic question regarding the proper syntax for a simple if statement I'm trying to write with R (having a background in coding with Python). What would be the R equivalent to the Python statement:

def zsco(data, mean, sd):
    if sd==0:
        z=0
    else:
        z=abs((data-mean)/sd)
    return z

Thank you! :)

Aucun commentaire:

Enregistrer un commentaire