sorting - How to preserve the order of a vector in a table in R? -
pretty simple question, assume. trying different type of object (with class 'acf' , type 'list'), assume answer extendable vector (class numeric, type 'double'):
x<-c(4, 5, 6, 1, 2, 10, 15) table(x) x 1 2 4 5 6 10 15 1 1 1 1 1 1 1
i output of table in same order vector (4, 5, 6, 1, 2, 10, 15). how can achieve this?
table(factor(x, levels=unique(x)))
Comments
Post a Comment