Scientific Notation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Scientific Notation

Jacques Wagnor
Dear List:

Below is how I specify an axis:

axis(2, at=c(0.00005, 0.0005))

R displays the numbers in scientific notation.  What
argument/parameter should I use to tell R to display the numbers as
specified rather than in scientific notation?

> version
               _
platform       i386-pc-mingw32
arch           i386
os             mingw32
system         i386, mingw32
status
major          2
minor          5.1
year           2007
month          06
day            27
svn rev        42083
language       R
version.string R version 2.5.1 (2007-06-27)

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Scientific Notation

Duncan Murdoch
On 9/26/2007 11:24 AM, Jacques Wagnor wrote:
> Dear List:
>
> Below is how I specify an axis:
>
> axis(2, at=c(0.00005, 0.0005))
>
> R displays the numbers in scientific notation.  What
> argument/parameter should I use to tell R to display the numbers as
> specified rather than in scientific notation?

Something like

axis(2, at=c(0.00005, 0.0005), labels=c("0.00005", "0.0005"))

is a way to be 100% sure of what will be displayed, but in this
particular instance,

at <- c(0.00005, 0.0005)
axis(2, at=at, labels=format(at, sci=FALSE))

comes close, and there may be some other format spec that gets exactly
what you want.

Duncan Murdoch

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Scientific Notation

Francisco J. Zagmutt
I believe the argument to format is "scientific" i.e.
axis(2, at=at, labels=format(at, scientific=FALSE))

Best regards,

Francisco

Duncan Murdoch wrote:

> On 9/26/2007 11:24 AM, Jacques Wagnor wrote:
>> Dear List:
>>
>> Below is how I specify an axis:
>>
>> axis(2, at=c(0.00005, 0.0005))
>>
>> R displays the numbers in scientific notation.  What
>> argument/parameter should I use to tell R to display the numbers as
>> specified rather than in scientific notation?
>
> Something like
>
> axis(2, at=c(0.00005, 0.0005), labels=c("0.00005", "0.0005"))
>
> is a way to be 100% sure of what will be displayed, but in this
> particular instance,
>
> at <- c(0.00005, 0.0005)
> axis(2, at=at, labels=format(at, sci=FALSE))
>
> comes close, and there may be some other format spec that gets exactly
> what you want.
>
> Duncan Murdoch
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Scientific Notation

Prof Brian Ripley
On Wed, 26 Sep 2007, Francisco J. Zagmutt wrote:

> I believe the argument to format is "scientific" i.e.
> axis(2, at=at, labels=format(at, scientific=FALSE))

Yes, but abbreviations of argument names are allowed.

Here setting a small positive value of options(scipen) (e.g. 2) gives
floating-point notation as in

> at <- c(0.00005, 0.0005)
> options(scipen=2)
> as.character(at)
[1] "0.00005" "0.0005"
> axis(2, at=at, labels=as.character(at))

would do the job (and in many similar cases).

>
> Best regards,
>
> Francisco
>
> Duncan Murdoch wrote:
>> On 9/26/2007 11:24 AM, Jacques Wagnor wrote:
>>> Dear List:
>>>
>>> Below is how I specify an axis:
>>>
>>> axis(2, at=c(0.00005, 0.0005))
>>>
>>> R displays the numbers in scientific notation.  What
>>> argument/parameter should I use to tell R to display the numbers as
>>> specified rather than in scientific notation?
>>
>> Something like
>>
>> axis(2, at=c(0.00005, 0.0005), labels=c("0.00005", "0.0005"))
>>
>> is a way to be 100% sure of what will be displayed, but in this
>> particular instance,
>>
>> at <- c(0.00005, 0.0005)
>> axis(2, at=at, labels=format(at, sci=FALSE))
>>
>> comes close, and there may be some other format spec that gets exactly
>> what you want.
>>
>> Duncan Murdoch
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>
> ______________________________________________
> [hidden email] 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.
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] 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.