Wolfram Fischer
2004-Nov-10 11:28 UTC
[R] lattice: ordering the entries in a dotplot of a vector
I tried: n <- 9 x <- sample(n) names(x) <- LETTERS[1:n] dotplot( sort(x) ) The lines of the dotplot are not ordered according to the values of x (but according to the names of x). So I did: dfx <- data.frame( x=x, label=factor( names(x), names(x)[order(x)] ) ) dotplot( label ~ x, data=dfx ) So I got what I wanted. My question: Is there an easier solution for doing that? Wolfram
Deepayan Sarkar
2004-Nov-10 16:47 UTC
[R] lattice: ordering the entries in a dotplot of a vector
On Wednesday 10 November 2004 05:28, Wolfram Fischer wrote:> I tried: > n <- 9 > x <- sample(n) > names(x) <- LETTERS[1:n] > dotplot( sort(x) ) > > The lines of the dotplot are not ordered according to the values of x > (but according to the names of x). > > So I did: > > dfx <- data.frame( x=x, label=factor( names(x), > names(x)[order(x)] ) ) dotplot( label ~ x, data=dfx ) > > So I got what I wanted. > > My question: Is there an easier solution for doing that?It should have been the default behaviour (according to S-PLUS). The next release should fix this. Deepayan
Apparently Analagous Threads
- lattice: defining an own function using args for "formula" and "groups"
- lattice: showing panels for factor levels with no values
- lattice/grid: problem with viewports for strips with zero height
- lattice: adding text between grouped panels?
- inverse function of order()