lundi 2 mars 2020

Unexpected '{' and 'else'

Trying to make a function where a vector for "scores" can be saved, and then this function would determine the qualitative rating of the score. I've rearranged my brackets multiple times, but I still get those errors. Also getting errors with the "else" as well.

    credit_fun <- function(scores){
      if (scores>300 & scores<579)(incbounds = TRUE){
    'Very Poor';
    } else if (scores>580 & scores<669)(incbounds = TRUE){
    'Fair';
    } else if (scores>670 & scores<739)(incbounds = TRUE){
    'Good';
    } else if (scores>740 & scores<799)(incbounds = TRUE){
    'Very Good';
    } else if (scores>800 & scores<850)(incbounds = TRUE){
    'Exceptional'}
}

Aucun commentaire:

Enregistrer un commentaire