dimanche 31 janvier 2016

Function with Else if not working in R

I have created a function in R using if else statement inside the function.

use.switch <- function(x)
{
 if is.character(x)
{
 switch(x,
        "ram" = 1,
        "mike" = 2,
        "king" = 3,
        "others")
} else
{
 Print("Kindly provide the correct input !!!")
}
}

If i run the above code i am getting the below error message,

**Error: could not find function "Print"

} Error: unexpected '}' in "}"**

Could anyone tell me what is wrong in the above code and how to correct it.

Regards, Mohan

Aucun commentaire:

Enregistrer un commentaire