[R] Horizontal stripplot

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Dec 5 10:56:18 CET 2006


On 12/5/06, Johan Sandblom <jsandblom at gmail.com> wrote:
> I have a plot similar to the following
>
> library(lattice)
> stripplot(1:15, rep(1:3, each=5))

That doesn't look like a meaningful call. Did you mean something like

stripplot(1:15 ~ rep(1:3, each=5))

?

In any case, the 'horiz(ontal)' argument is meant for unusual
situations, you shouldn't need to use it. One of the variables in a
strip plot is supposed to be a categorical variable, and categorical
variables are represented by factors in R. Instead of using numeric
variables as in your example, use factors, and you should be fine. For
example, this gives me horizontal strip plots:

stripplot(factor(rep(1:3, each=5)) ~ 1:15)

and this vertical:

stripplot(1:15 ~ factor(rep(1:3, each=5)))

> In order to save space for a presentation, I would like to have
> horizontal strips instead of vertical. The argument 'horiz' turns the
> arguments around, but not the plot. The documentation for 'stripplot'
> ('xyplot'), 'panel.stripplot' and the FAQ do not seem to provide
> insight. Any help appreciated.

The documentation for 'stripplot' says:

          ... In the other four functions documented here,
          exactly one of 'x' and 'y' should be numeric, and the other a
          factor or shingle. Which of these will happen is determined
          by the 'horizontal' argument - if 'horizontal=TRUE', then 'y'
          will be coerced to be a factor or shingle, otherwise 'x'. The
          default value of 'horizontal' is 'FALSE' if 'x' is a factor
          or shingle, 'TRUE' otherwise.

which part is unclear?

-Deepayan




More information about the R-help mailing list