On Jul 4, 2013, at 8:14 PM, Eric Archer - NOAA Federal wrote: > I have a character vector that I'm using to label ticks in a dotchart. Some > of the elements in the vector have an asterisk (*) where a Greek Delta > needs to be placed when the plot is generated. Here's a simple example: > > x <- 1:4 > x.lab <- c("a*a", "bbb", "c*c", "ddd") > dotchart(x, labels = x.lab) > > The first and third labels should be 'a<Delta>a' and 'c<Delta>c'. I've > tried things like, > > x.lab <- strsplit(x.lab, "[*]") > x.lab <- lapply(x.lab, function(y) expression(paste(y, sep = Delta))) > > but because 'y' is unevaluated, the resulting list elements won't work as > tick labels. I've tried to modify it by using bquote and substitute, but > couldn't get anything closer. Any suggestions? Thanks!
Right. I would not throw away the "*" but rather change it to an inline Delta: x.lab <- gsub("\\*", "*Delta*", x.lab) # parse(text=x.lab) # returns: expression(a*Delta*a, bbb, c*Delta*c, ddd)# Then parse it: dotchart(x, labels = parse(text=x.lab) ) > > Cheers, > eric > > -- > > Eric Archer, Ph.D. > Southwest Fisheries Science Center > NMFS, NOAA > 8901 La Jolla Shores Drive > La Jolla, CA 92037 USA > 858-546-7121 (work) > 858-546-7003 (FAX) > > Marine Mammal Genetics Group: swfsc.noaa.gov/prd-mmgenetics > ETP Cetacean Assessment Program: swfsc.noaa.gov/prd-etp > > "The universe doesn't care what you believe. > The wonderful thing about science is that it > doesn't ask for your faith, it just asks > for your eyes." - Randall Munroe > > "Lighthouses are more helpful than churches." > - Benjamin Franklin > > "...but I'll take a GPS over either one." > - John C. "Craig" George > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. David Winsemius Alameda, CA, USA ______________________________________________ R-help@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.