dimanche 2 septembre 2018

ifelse() and paste0() in a vector

I've got a vector (mychipvalue) with a single numeric element in it.

If the numeric is 0, I'd like to replace it with "<0.001". If the numeric is not 0 but eg 0.053 I'd like to leave it untouched (keep 0.053).

Thanks for any help!

mychipvalue <- 0 
mychipvalue < ifelse(mychipvalue==0,paste0("<0.001"),paste0(mychipvalue))

Aucun commentaire:

Enregistrer un commentaire