0

I am working with a data frame. I would like to order the data frame by its rownames.

I tried using the sort function

sort(mydataframe$rownames, pattern="Lung", full.names = TRUE)

This is the data frame that I am working with:

     input filtered denoisedF denoised merged nonchim
Lung 41229    39034     38724    38088  37693   37693
Oral 36891    33654     33276    32474  29641   28513
Lung 15366    14201     13564    10355   7820    7815
.
.
.

My expected output is something like this:

     input filtered denoisedF denoised merged nonchim
Lung 41229    39034     38724    38088  37693   37693
Lung 15366    14201     13564    10355   7820    7815
Oral 36891    33654     33276    32474  29641   28513
.
.
.
Noah_Seagull
  • 337
  • 5
  • 18

1 Answers1

0

Using the tidyverse, I would do the following:

library(tidyverse)
df %>% 
  rownames_to_column() %>% 
  arrange(rowname)
yfa
  • 101
  • 5