How to use quantile function within lapply in R

Hello everyone,

I am having trouble in using quantile function within lapply function. I have a list of data frames and each data frame has a variable name TOTAL_INCOME. So I want to apply quantile function based on the TOTAL_INCOME variable on each data frame. I am running following code but id does not work.

#All_income is a list of data frame having multiple common variables.
#TOTAL_INCOME is a common variable in all the dataframe
quant_income= lapply(All_incom,quantile,All_incom[[]]$TOTAL_INCOME)


So how can I make it work?

alist <- split(iris, iris$Species)
str(alist)

lapply(alist, function(x) quantile(x[["Sepal.Length"]]))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.