I am desperately trying to sort a dataframe ("transp_correlations) by one column "corr" (ideally in descending order). Waht I need to be returned is the complete dataframe (incl. its rownames).
Unfortunately I face a lot of issues - what I tried is
- transp <- transp_correlations[order(corr), ] --> which returns a scalar (the first cell of the dataframe)
- transp <- transp_correlations[order(transp_correlations$corr), ] --> which returns a sorted vector but deletes the rownames
- transp <- transp_correlations[order("corr") ] --> which returns a non-sorted data frame
According to my knowledge the first option is the correct syntax and I identified the other two only by chance. Any guidance how to write a correct syntax would be highly appreciated.
structure(list(corr = c(-0.117661691889059, -0.244374051965591, -0.219277156640164, -0.162119035544463, -0.153750058161601, 0.238059055122716, -0.112988647529562, -0.22890950435724, -0.212213257871138, -0.164868801623183, -0.157327010028056, 0.276036409162576, -0.129156901338342, -0.247314062599315, -0.234716884100804, -0.177925630373387, -0.164633635391903, 0.227786973830269, -0.10921452701353, -0.0385193717439635), abscorr = c(0.117661691889059, 0.244374051965591, 0.219277156640164, 0.162119035544463, 0.153750058161601, 0.238059055122716, 0.112988647529562, 0.22890950435724, 0.212213257871138, 0.164868801623183, 0.157327010028056, 0.276036409162576, 0.129156901338342, 0.247314062599315, 0.234716884100804, 0.177925630373387, 0.164633635391903, 0.227786973830269, 0.10921452701353, 0.0385193717439635), rang = c(62L, 108L, 96L, 85L, 80L, 105L, 61L, 100L, 94L, 89L, 82L, 115L, 70L, 110L, 103L, 91L, 88L, 98L, 59L, 36L)), .Names = c("corr", "abscorr", "rang"), row.names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", "V11", "V12", "V13", "V14", "V15", "V16", "V17", "V18", "V19", "V20" ), class = "data.frame")