[R] how to draw a stripplot in vertical orientation, using lattice

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Fri May 19 23:03:34 CEST 2023


Well, my aesthetic sense is not offended, so:

dd |> stripplot(height ~ "", data = _, horizontal = FALSE)
## seems fine to me.

## But if you prefer, the following is a more verbose but maybe more
"seemly" version :-)  :
 dd |> stripplot(height ~ 1, data = _, horizontal = FALSE,
          xlab = "", scales = list(x = list(draw = FALSE)))
******************
Notes:
1. You can use R's native pipe operator instead of magrittr's (one less package)
2. The "scales" argument controls tick marks and their labels for axis
in lattice. See ?xyplot for details.

Cheers,
Bert

On Fri, May 19, 2023 at 1:30 PM Christopher Ryan via R-help
<r-help using r-project.org> wrote:
>
> I'm attempting to describe the height of a fall from a building, so the
> vertical orientation has a certain attraction.
>
> dd <- data.frame(nothing = rep(1:2, each = 6), height = runif(n=12, min=0,
> max=30))
> dd
>
> ## pretty much what I'm looking for
> with(dd, stripchart(height, vertical = TRUE))
>
> ## but if possible  would like to do it with lattice and pipes
> library(lattice)
> library(dplyr)
>
> dd %>% stripplot(~height, data = .)  ## default is horizontal
> dd %>% stripplot(~height, data = ., horizontal = FALSE)    ## no
> dd %>% stripplot(height ~, data = ., horizontal = FALSE)   ## a guess,
> clearly not right
> dd %>% stripplot(height ~ 1, data = ., horizontal = FALSE)  ## close, but
> x-axis label and tic labels undesired
> dd %>% stripplot(height ~ 1, data = ., horizontal = FALSE, xlab = NULL)  ##
> closer
> dd %>% stripplot(height ~ "", data = ., horizontal = FALSE)
>
> The last line gets pretty much what I'm looking for, but it feels a bit . .
> . unseemly.  height ~ "" ? There must be a more proper way, that I'm just
> not thinking of.
>
> Thanks.
>
> --Chris Ryan
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list