Santosh
2013-Jun-05 02:39 UTC
[R] Expression evaluation of Plotting labels containing spaces
Dear Rxperts, How do I overcome the anomaly as in the second case of examples below? exc <- list(units=list( c(m^2)) ,vars= list(c('asb')), ,label= list(c('abs surf body'))) plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],' (',exc$units[1],')',sep=''))) plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],' (',exc$units[1],')',sep=''))) Thanks so much! Santosh [[alternative HTML version deleted]]
Pascal Oettli
2013-Jun-05 02:48 UTC
[R] Expression evaluation of Plotting labels containing spaces
Hello, Example not reproducible: > exc <- list(units=list( c(m^2)) ,vars= list(c('asb')), ,label= list(c('abs surf body'))) Error: object 'm' not found Regards, Pascal On 05/06/13 11:39, Santosh wrote:> Dear Rxperts, > How do I overcome the anomaly as in the second case of examples below? > > exc <- list(units=list( c(m^2)) ,vars= list(c('asb')), ,label= list(c('abs > surf body'))) > > plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],' > (',exc$units[1],')',sep=''))) > > plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],' > (',exc$units[1],')',sep=''))) > > Thanks so much! > > Santosh > > [[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. >
Pascal Oettli
2013-Jun-05 04:08 UTC
[R] Expression evaluation of Plotting labels containing spaces
Hi, On possibility is: par(mfrow=c(2,1), mar=c(5.1,5.1,4.1,2.1)) plot(1,1, ylab=expression(a.s.b.~(m^2))) plot(1,1, ylab=expression(abs~surf~body~(m^2))) Regards, Pascal On 05/06/13 11:39, Santosh wrote:> Dear Rxperts, > How do I overcome the anomaly as in the second case of examples below? > > exc <- list(units=list( c(m^2)) ,vars= list(c('asb')), ,label= list(c('abs > surf body'))) > > plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],' > (',exc$units[1],')',sep=''))) > > plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],' > (',exc$units[1],')',sep=''))) > > Thanks so much! > > Santosh > > [[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. >
David Winsemius
2013-Jun-05 04:13 UTC
[R] Expression evaluation of Plotting labels containing spaces
On Jun 4, 2013, at 8:39 PM, Santosh wrote:> Dear Rxperts, > How do I overcome the anomaly as in the second case of examples below? > > exc <- list(units=list( c(m^2)) ,vars= list(c('asb')), ,label= > list(c('abs > surf body'))) > > plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],' > (',exc$units[1],')',sep=''))) > > plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],' > (',exc$units[1],')',sep='')))Mail client mangled this due entirely to your improper use HTML. You have been posting to Rhelp long enough to have had plenty of opportunity to read the Posting Guide. And I know for a fact that it is quite easy to send plain text using gmail. You have no legitimate excuse for continuing this deprecated practice. Anyway, running this code: exc <- list(units=list( c("m^2")) ,vars= list(c('asb')), label= list(c('abs surf body'))) # Notice that I quoted the 'units' value plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],'(',exc $units[1],')',sep=''))) # Also note that plotmath cannot handle embedded carriage returns plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],'(',exc $units[1],')',sep=''))) Produces this error: Error in parse(text = paste(exc$label[1], "(", exc$units[1], ")", sep = "")) : <text>:1:5: unexpected symbol 1: abs surf ^ (You are asked in the Posting Guide exactly your code and also to post your error messages.) So you are trying to parse an expression and the parser is expecting a comma or a tilde or .... something other than the beginning of another token. You never said what you actually wanted (also a request in the Posting Guide), but try adding tilde's: exc <- list(units=list( c("m^2")) ,vars= list(c('asb')), label= list(c('abs~surf~body'))) plot(1:10,1:10, ylab=parse(text= paste(exc$vars[1],'(',exc $units[1],')',sep=''))) plot(1:10,1:10, ylab=parse(text= paste(exc$label[1],'(',exc $units[1],')',sep=''))) I know that the plotmath help page is not exactly the most expansive regarding how to form proper expressions for R but at least review it and run the examples: ?plotmath -- David.> > Thanks so much! > > Santosh > > [[alternative HTML version deleted]]Sigh.> > > 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.--- David Winsemius, MD Alameda, CA, USA