[R] Plotting Multiple Factors By Dates With Lattice
arun
smartpink111 at yahoo.com
Fri Aug 16 19:46:28 CEST 2013
You could remove the white space also by:
library(stringr)
levels(bdf$func_feed_grp)
#[1] "Filterer" " Gatherer " " Grazer " " Omnivore "
#[5] " Parasite " " Predator " " Shredder "
levels(bdf$func_feed_grp)<- str_trim(levels(bdf$func_feed_grp))
levels(bdf$func_feed_grp)
#[1] "Filterer" "Gatherer" "Grazer" "Omnivore" "Parasite" "Predator" "Shredder"
A.K.
----- Original Message -----
From: Rich Shepard <rshepard at appl-ecosys.com>
To: R help <r-help at r-project.org>
Cc:
Sent: Friday, August 16, 2013 12:01 PM
Subject: Re: [R] Plotting Multiple Factors By Dates With Lattice
On Fri, 16 Aug 2013, Richard M. Heiberger wrote:
> The major problem is all the padding and the LF in the level names.
> This repair is based on the ?gsub example on "## trim trailing white space".
Rich
Thanks. I thought of removing white space (didn't notice the spurious
newline) in emacs but did not see that it made a difference. Now I know it
does I'll clean up all the files.
> I switched the key to "lines" to match the graph.
OK.
> You need to control the color choice differently when using a key.
> It is discussed in ?xyplot in the paragraph
> Note that 'simpleKey' uses the default settings (see
> 'trellis.par.get') to determine the graphical parameters in
> the key, so the resulting legend will be meaningful only if
> the same settings are used in the plot as well. The
> 'par.settings' argument may be useful to temporarily modify
> the default settings for this purpose.
I'll carefully read it.
> xyplot(pct ~ sampdate, data = bdf, groups = func_feed_grp, type = 'l',
> key = simpleKey(text = levels(bdf$func_feed_grp), space ='right',
> points=FALSE, lines=TRUE),
> par.settings=list(superpose.points=list(col=rainbow(7)),
> superpose.lines=list(col=rainbow(7))))
Valuable lessons learned here. Again, thanks.
Rich
______________________________________________
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