Friday, February 18, 2011

R generate factor levels - gl

> gl(2, 8, labels = c("Control", "Treat"))
[1] Control Control Control Control Control Control Control Control Treat
[10] Treat Treat Treat Treat Treat Treat Treat


> c('red','green','blue','brown','yellow')[brain[colSel, 'major_struct']]
[1] "brown" "red" "brown" "yellow" "yellow" "red" "red" "green"
[9] "yellow" "red" "red" "blue" "brown" "brown" "yellow" "green"
[17] "green" "red" "yellow" "brown" "blue" "green" "yellow" "red"
[25] "blue" "blue" "green" "blue" "red" "green" "yellow" "green"
[33] "yellow" "blue" "green" "blue" "yellow" "yellow" "yellow" "red"
[41] "red" "red" "yellow" "red" "green" "blue" "red" "green"
[49] "brown" "green" "blue" "blue" "blue" "yellow" "blue" "red"

No comments: