how do I subset data.frame data into three parts based on the values of one column? I want to show the u shape of a curve by building means within the different subsets. I already figured how to get a random top and bottom value, and how to get the top x and bottom x percent.. (e.g. 25%/50%/25%)
low.x <- top_n(final_data, -100, final_data$variablex)
high.x <- top_n(final_data, 100, final_data$variablex)
OR (sth. like... still gives me the wrong output for low.x)
n <- 25
low.x <- subset(final_data, final_data$variablex < quantile(final_data$variablex, prob = 1 - n/100))
high.si <- subset(final_data, final_data$variablex > quantile(final_data$variablex, prob = 1 - n/100))
But... How do I build the subsets based on lower 25%, main 50% and top 75%?
Thank you!