[R] {Lattice} help.

Greg Snow Greg.Snow at imail.org
Tue Dec 8 22:14:06 CET 2009


Here are a couple of others to try (using the lattice package):

dotplot(Factor1 ~ Value | Factor2, data=foo, groups=Factor3, auto.key=T)
dotplot(Factor1 ~ jitter(Value) | Factor2, data=foo, groups=Factor3, auto.key=T)
dotplot(Factor3 ~ Value | Factor2*Factor1, data=foo )
dotplot(Factor1:Factor3 ~ Value | Factor2, data=foo )

also see the dotchart2 function in the Hmisc package for another version of the dotplot.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Xin Ge
> Sent: Monday, December 07, 2009 6:50 PM
> To: r-help at r-project.org
> Subject: [R] {Lattice} help.
> 
> Hi All,
> 
> I have a 4-dimensional data. I'm using barchart() function from lattice
> package. The R code and data are below - code includes one for
> stack=TRUE
> and other for stack=FALSE.
> 
> I would like to present the data in another form which would be
> plotting
> Factor3 levels (P, Q, R, S) as two stacked bars (side by side). Like,
> for
> each level of Factor1 there should be two bars: first bar showing
> stacked
> values of "P" and "Q" and the adjacent bar showing stacked values of
> "R" and
> "S". Is it possible using barchart() function?
> 
> OR, if someone can give me some suggestions on the best way to present
> such data. Any help would be highly appreciated.
> 
> # Reading data in object "foo"
> 
> barchart(foo$Value ~ foo$Factor1 | foo$Factor2, data = foo,
>          groups = foo$Factor3, stack = TRUE,
>          auto.key = list(points = FALSE, rectangles = TRUE, space =
> "right"))
> barchart(foo$Value ~ foo$Factor1 | foo$Factor2, data = foo,
>          groups = foo$Factor3, stack = FALSE,
>          auto.key = list(points = FALSE, rectangles = TRUE, space =
> "right"))
> 
> # Data
> 
> Factor1    Factor2    Factor3    Value
> A    X    P    10
> A    X    Q    20
> A    X    R    10
> A    X    S    20
> A    Y    P    20
> A    Y    Q    5
> A    Y    R    20
> A    Y    S    5
> B    X    P  20
> B    X    Q    10
> B    X    R    20
> B    X    S    10
> B    Y    P    30
> B    Y    Q    50
> B    Y    R    30
> B    Y    S    50
> Thanks,
> ~Xin
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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