[R] custom tick mark labels on bwplot

Deepayan Sarkar deepayansarkar at yahoo.com
Tue Apr 30 21:46:03 CEST 2002


--- Scot W McNary <smcnary at fellspt.charm.net> wrote:
> 
> Hi,
> 
> I could use some help figuring out how to make some more useful tickmark
> labels in a set of box and whisker plots I've made.  I'm really happy with
> the bwplot code I'm using (borrowed heavily from examples) as it gives me
> three sets of boxplots for each group (sourcedx) across seven variables
> (X.NAME) all on the same page.  The problem is, I'd like to label the sets
> of tickmarks with something less cumbersome than the original variable
> labels (X.LABEL).
> 
> I've been playing around with strsplit:
> 
> lab1<-unlist(strsplit(milk$X.LABEL, "-"))
> 
> to try to get the label to pull off the part of X.LABEL before the
> 
> "- times/month" or "- times/mo"
> 
> that appears in each label.  That should give me a shorter but still
> sufficiently descriptive label.
> 
> However, I can't seem to figure out how to get just that first part, since
> what I end up with is a list:


unlist(lapply(strsplit(dtf$X.LABEL, "-"), "[", 1))

seems to work. abbreviate() can abbreviate strings, but the results
might not be informative enough.


> [1] "Chocolate milk and hot cocoa "  " times/mo"
> "Milk to drink or on cereal "
> [4] " times/month"                   "Yogurt and frozen yogurt "      "
> times/month"
> [7] "Ice cream,ice milk,milkshakes "
> 
> Do I then figure out how to pick elements out of the list, or is there a
> better way to trim a character variable?
> 
> 
> 
> My dataset (milk) looks like this:
> 
>      id X.NAME.                                 X.LABEL. amt1 sourcedx
> nh10000  HAN1AS  Chocolate milk and hot cocoa - times/mo    0.00 NHANE
> nh10000  HAN1BS Milk to drink or on cereal - times/month   30.00 NHANE
> nh10000  HAN1ES   Yogurt and frozen yogurt - times/month    0.00 NHANE
> nh10000  HAN1FS Ice cream,ice milk,milkshakes - times/mo    4.00 NHANE
> nh10000  HAN1GS          Cheese, all types - times/month   17.00 NHANE
> nh10000  HAN1HS    Pizza, calzone, lasagna - times/month    0.00 NHANE
> nh10000  HAN1IS              Cheese dishes - times/month    3.00 NHANE
> sp60048  HAN1AS  Chocolate milk and hot cocoa - times/mo    0.00 SOCOp
> sp60048  HAN1BS Milk to drink or on cereal - times/month   30.40 SOCOp
> sp60048  HAN1ES   Yogurt and frozen yogurt - times/month    0.00 SOCOp
> sp60048  HAN1FS Ice cream,ice milk,milkshakes - times/mo    2.00 SOCOp
> sp60048  HAN1GS          Cheese, all types - times/month   30.40 SOCOp
> sp60048  HAN1HS    Pizza, calzone, lasagna - times/month    2.00 SOCOp
> sp60048  HAN1IS              Cheese dishes - times/month    1.00 SOCOp
> sa30007  HAN1AS  Chocolate milk and hot cocoa - times/mo   12.90 SOCOa
> sa30007  HAN1BS Milk to drink or on cereal - times/month   60.80 SOCOa
> sa30007  HAN1ES   Yogurt and frozen yogurt - times/month    NA   SOCOa
> sa30007  HAN1FS Ice cream,ice milk,milkshakes - times/mo   30.40 SOCOa
> sa30007  HAN1GS          Cheese, all types - times/month    0.00 SOCOa
> sa30007  HAN1HS    Pizza, calzone, lasagna - times/month    0.00 SOCOa
> sa30007  HAN1IS              Cheese dishes - times/month    4.00 SOCOa
> sa30009  HAN1AS  Chocolate milk and hot cocoa - times/mo    0.00 SOCOa
> 
> Thanks,
> 
> Scot
> 
> 
> 
> --
>   Scot W. McNary  email:smcnary at charm.net
> 
> 
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


__________________________________________________

Yahoo! Health - your guide to health and wellness

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list