yet another way, > x <- read.table(textConnection("Category Value + b 1 + b 2 + a 7 + a 1"), header=TRUE) > y = transform(x, Category = relevel(Category, c("b"))) > str(y) 'data.frame': 4 obs. of 2 variables: $ Category: Factor w/ 2 levels "b","a": 1 1 2 2 $ Value : int 1 2 7 1
HTH, baptiste 2009/9/23 Chris Li <chri...@austwaterenv.com.au>: > > Hello, > > Say I have a dataset as followed: > > Category Value > b 1 > b 2 > a 7 > a 1 > > Then, if I: > > levels(Category) > > It will return: > [a], [b] > > But I want to keep the original order, i.e.: > [b], [a] > > Is it possible to do it in R? > > Thanks in advance! > > Chris > -- > View this message in context: > http://www.nabble.com/Sorting-tp25531007p25531007.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.