I have a data frame like the following:
c1 <- c(324, 213, 122, 34)
c2 <- c("SDOIHHFOEKN", "SDIUFONBSD", "DSLIHFEIHDFS", "DOOIUDBD")
c3 <- c("G", "T", "U", "T")
df <- data.frame(count = c1, seq = c2, other = c3)
I want the top N sequences in a data frame. For example, for N = 600, I want the final data frame to have a column sum of count to be 600, meaning that only the top 3 rows of this data frame would remain, and the count of the third row would now be 600-324-213 = 63.
How can I get the output data frame like this?
I would really appreciate it if you could provide a general solution, as the data frame I am working with has over 1000 rows and smaller numbers.
Thanks!