r - sorting output by part of header -


i output using coxme model. i'm trying work part, frailty/re output, looks this.

>fitpm50$frail$'st_baseline/cmsa_msa' ca/680       ca/2840       ca/4472       ca/6922       ca/7120       ca/7320   1.129591e-02 1.208329e-02 -3.709842e-02  2.353560e-02 -3.345176e-04  1.359872e-02   

i sort , output data frame. tricky part here want sort number, removing ca/. came this:

>sort(as.character(substring(attributes(fitpm50$frail$'st_baseline/cmsa_msa')$names, 4, 7) 

which sort of works, returns 680 third biggest value, whereas want 680 smallest. returns sorted values headers, whereas want whole output sorted data frame.

thanks

you sorting on character strings, not numbers. if want sort numeric values, need convert numbers.

rgames> foo<-c('680','780','1290','450','1100') rgames> sort(as.numeric(foo)) [1]  450  680  780 1100 1290 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -