Skip to content
Prev 318626 / 398506 Next

Ordering Table Columns

cdouglass wrote
Think you want to have a look at factors.... 

Typing ?factor will throw up the relevant help pages  

# Your Data
tbl <- read.table(header = TRUE, text = "
 ShirtSize Number 
 L 20     
 M 20     
 S 11     
 XL 7     
 XXL 2   
")

# ShirtSize Alphabetical
tbl[tbl$ShirtSize,]

# Reorder Factor
tbl$ShirtSize = factor(tbl$ShirtSize, levels=c("S","M","L","XL","XXL"))

# ShirtSize Order by Size
tbl[tbl$ShirtSize,]


Pete



--
View this message in context: http://r.789695.n4.nabble.com/Ordering-Table-Columns-tp4660110p4660129.html
Sent from the R help mailing list archive at Nabble.com.