I am attempting to assign a number from 1 through 10 to a series of vectors based on what quantile they're in in a dataframe.
So far I have tried
quants <- quantile(Data$Avg, c(.1, .2, .3, .4, .5, .6, .7, .8, .9))
Data$quant <- for ( i in nrow(Data) ) {
ifelse(Data$Avg [i] < quants[1], Data$quant[1] = 1 ,
ifelse(Data$Avg [i] > quants[1] & Data$Avg[i] < quants[2], Data$quant[1] = 2, Data$quant = 3
))}
I get the following mistake:
Can anyone spot the mistake I am making here?
Aucun commentaire:
Enregistrer un commentaire