Hi,
I think it's a stupid question but I cannot find a way to do it online. I have post it on bioconductor as well (https://support.bioconductor.org/p/133467/) I want to sort simultaneously all the columns of my dataframe from the biggest to the smallest number (decreasing order) keeping at the same time the first column that contains the gene names (=characters) since I need to know which gene is what after the other columns has been re-ordered.
my dataset:
#A tibble: 3 x 12
gene_symbol `control 0hr` `control 24hr`
<chr> <dbl> <dbl>
1 5-8S 270. 146.
2 5S 123. 129.
3 7SK 56.6 31.0
the only thing that works is selecting the numeric columns that I want to sort but in doing so I will lose the names of the genes:
CD.sorted <- apply(test[4:14],2,sort,decreasing=T)
if I run this the order is not decreasing and the number are all messed up (I got either all 0 or 9.99):
CD.sorted2 <- apply(test,2,sort,decreasing=T)
and if I run this code, the order is not decreased and all the number are again changed but I don't understand how:
library(dplyr)
f <- test %>% mutate_at(4:14, funs(sort(., decreasing = TRUE)))
and if I run this (where I tell exactly which columns to order) there is no changes at all:
CD.sorted2 <- arrange(test, desc("control 0hr", "control 24hr","control 48hr","control 54hr", "control 60hr","control 66hr","control 72hr","control 96hr","control 120hr" ,"control 144hr", "control 168hr" ))
thank you
Camilla
This question belongs on biostars, not on bioC. However, your post there has more responses to it, which makes it confusing for people to follow. Please be more careful in the future - questions having to do with bioconductor packages go there, other bioinformatics questions go here.
oh ok. I did know. I realized after I posted on bioconductor. can I cancel one of the 2 post?
Don't worry about it now, once you get an answer that works, add an answer on the other post pointing to that answer.