Benjamin Gillespie
2013-Mar-18 20:29 UTC
[R] Superscript followed by number then superscript in text
Hi all, I'm having problems finding the correct format for a command. I would like to write some text on a plot. I'm using the following command: text(x,y,"text here", srt=90) I would like the text to read: capacity 10^3 m^3 (with ^ denoting superscript (i.e. each '3' as superscript). I've tried fiddling around with expression(paste(etc.... to no avail. I receive errors such as: "Error: unexpected numeric constant..." Anyone had experience with this before? Any suggestions would be great. Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT
Thomas Lumley
2013-Mar-18 20:54 UTC
[R] Superscript followed by number then superscript in text
On Tue, Mar 19, 2013 at 9:29 AM, Benjamin Gillespie <gybrg@leeds.ac.uk>wrote:> Hi all, > > I'm having problems finding the correct format for a command. > > I would like to write some text on a plot. > > I'm using the following command: > > text(x,y,"text here", srt=90) > > I would like the text to read: > > capacity 10^3 m^3 > > (with ^ denoting superscript (i.e. each '3' as superscript). >What did you try? Anyhow, this works text(1,1,expression("capacity"~10^3~m^3)) -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland [[alternative HTML version deleted]]
Rui Barradas
2013-Mar-18 21:00 UTC
[R] Superscript followed by number then superscript in text
Hello, Something like this? plot(1, type = "n") text(1,1, expression(capacity ~ 10^3 ~ m^3)) Hope this helps, Rui Barradas Em 18-03-2013 20:29, Benjamin Gillespie escreveu:> Hi all, > > I'm having problems finding the correct format for a command. > > I would like to write some text on a plot. > > I'm using the following command: > > text(x,y,"text here", srt=90) > > I would like the text to read: > > capacity 10^3 m^3 > > (with ^ denoting superscript (i.e. each '3' as superscript). > > I've tried fiddling around with expression(paste(etc.... to no avail. I receive errors such as: "Error: unexpected numeric constant..." > > Anyone had experience with this before? Any suggestions would be great. > > Many thanks in advance, > > Ben Gillespie > Research Postgraduate > > School of Geography > University of Leeds > Leeds > LS2 9JT > ______________________________________________ > 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. >
Benjamin Gillespie
2013-Mar-19 09:23 UTC
[R] Superscript followed by number then superscript in text
Thanks to Dennis, Thomas and Rui - I was missing the "~". Many thanks, Ben Gillespie Research Postgraduate ________________________________________ From: Dennis Murphy [djmuser at gmail.com] Sent: 18 March 2013 20:47 To: Benjamin Gillespie Subject: Re: [R] Superscript followed by number then superscript in text Hi: plot(1, 1) text(1, 0.8, expression("capacity"~10^3~"m"^3)) Dennis On Mon, Mar 18, 2013 at 1:29 PM, Benjamin Gillespie <gybrg at leeds.ac.uk> wrote:> Hi all, > > I'm having problems finding the correct format for a command. > > I would like to write some text on a plot. > > I'm using the following command: > > text(x,y,"text here", srt=90) > > I would like the text to read: > > capacity 10^3 m^3 > > (with ^ denoting superscript (i.e. each '3' as superscript). > > I've tried fiddling around with expression(paste(etc.... to no avail. I receive errors such as: "Error: unexpected numeric constant..." > > Anyone had experience with this before? Any suggestions would be great. > > Many thanks in advance, > > Ben Gillespie > Research Postgraduate > > School of Geography > University of Leeds > Leeds > LS2 9JT > ______________________________________________ > 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.