How to write a function whose input is a vector and output is a character vector based on quantile...
0
0
I am writing a funcion whose input is a vector and output is a character vector of three levels: Below Avg, Avg, and Above Avg. I would like the character vector to be calucalted based on the 1st and 3rd quantiles of the vector given. When I call my function, only Below Avg returns which I understand why it returns, but do not know how to fix. Ideally I would like a new vector such that Below Avg corresponds to the values below the 1st quantile, Above Avg corresponds to values above the 3rd quantile, and Avg is everything in between. x<-c(1:10) label_scale<-function(vecrr){ lq<-quantile(vecrr,0.25) uq<-quantile(vecrr,0.75) if(vecrr<=lq){ k<-'Below Avg.' } else if(vecrr>=uq){ k<-'Above Avg.' } else{ k<-'Avg.'} return(k) } y...