[R] lattice strip.custom function

Bert Gunter bgunter.4567 at gmail.com
Sun Jul 5 06:31:30 CEST 2015


1. Please do not post in HTML. This is a plain text list and it can get mangled.

2. Thank you for the example data and code. The problem is -- see the
Help for strip.custom()  -- that strip.custom() wants a character
vector or expression for the factor.levels argument. But...

> str(dist.names)
 Factor w/ 3 levels "normal","t","uniform": 1 1 2 3

So dist.names is a factor, not a character vector. (I presume you know
the difference! If not, you need to do your homework and read an R
tutorial or two). Thus, this works:

histogram(~x | name, data = my.df,
      strip = strip.custom(factor.levels=as.character(dist.names)))

Cheers,
Bert


Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Sat, Jul 4, 2015 at 6:53 PM, Naresh Gurbuxani
<naresh_gurbuxani at hotmail.com> wrote:
> I would like to use a mapping to name panel strips.  Directly using mapping table does not work.  What is the problem here?
> my.df <- data.frame(x = rnorm(100, mean = 0, sd = 2), name = "A")
> my.df <- rbind(my.df, data.frame(x = rnorm(100, mean = 0, sd = 4), name = "B"))
> my.df <- rbind(my.df, data.frame(x = rt(100, 3), name = "C"))
> my.df <- rbind(my.df, data.frame(x = runif(100, min = -3, max = 3), name = "D"))
>
>
> library(lattice)
> histogram(~x | name, data = my.df)
> name.dist <- data.frame(name = c("A", "B", "C", "D"), dist = c("normal", "normal", "t", "uniform"))
> dist.names <- name.dist$dist
>
> # Below code workshistogram(~x | name, data = my.df, strip = strip.custom(factor.levels = c("normal", "normal", "t", "uniform")))
> # Below code does not workhistogram(~x | name, data = my.df, strip = strip.custom(factor.levels = dist.names))
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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