jeudi 29 juillet 2021

Ifelse(V>=80,"Above_Average","Average") in R printing extra spaces between last 2 outputs

I've a simple programming exercise in R, where I have to- Check each value of the vector V passed as a argument. If the marks are greater than or equal to 80 print Above_Average. If the marks are less than 80, print Average(in a single line).

Here's what I'm doing :-

conditional <- function(V)
{
ifelse(V>=80,"Above_Average","Average")
}
conditional(c(90,80,85,70,95))

output :-

[1] "Above_Average" "Above_Average" "Above_Average" "Average"       "Above_Average"

My concern is the extra space between last two outputs. Do you've any idea why I'm getting the extra space? And what is the solution for this?

Aucun commentaire:

Enregistrer un commentaire