I have a dataset:
MATRICULA <- c(111,222,444,1010,1020,777,888,999,555,666,333)
VALOR <- c(1000,2000,4000,10000,11000,7000,8000,9000,5000,6000,3000)
DADOS <- data.frame(MATRICULA, VALOR)
How to perform separately on the r tag the following two operations for the data.frame previously proposed?
DADOS
from highest VALOR
to lowest; In short, how do you sort the observations in a% w of% by the value of a column and select the observations that accumulate 50% of the value using the new data.frame
sorted?
My result should have only the registrations 1020,1010 and 999. In addition to the result only the 3 registrations, I would like the data.frame
column to also be displayed.
Thank you!