[R] Sort a data frame according to romans

Henrique Dallazuanna wwwhsd at gmail.com
Tue Dec 8 15:05:04 CET 2009


Try this:

mydata[order(as.roman(as.character(mydata$strata))),]

On Tue, Dec 8, 2009 at 11:59 AM, Luis Ridao Cruz <Luisr at hav.fo> wrote:
> R-help,
>
> I have a data frame:
>
>> mydata
>   strata nh  Nh    Wh    fh
> 1       I 10  26 0.048 0.385
> 2      II 32  84 0.154 0.381
> 3     III 16  42 0.077 0.381
> 4      IV  4  11 0.020 0.364
> 5       V 10  26 0.048 0.385
> 7     VII 64 168 0.309 0.381
> 8    VIII 49 129 0.237 0.380
> 9      IX 22  58 0.107 0.379
> 91     VI  0   0 0.000 0.000
>
> and I wish to rearrange the data are sorted according to the roman (first column):
>
> I,II,III,IV,V,VI,VII,VIII,IX
>
>
> Thanks in advance
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list