Scientific Notation

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

Scientific Notation

reichmaj
R Forum

Is there a way to tell R to not import numbers as scientific notation
(read.csv).  So that 1619052826499 will not be imported as 1.619053e+12.

Jeff Reichman

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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

David Carlson
You probably need to read up on the scipen= argument in ?options. What is displayed at the console is not what is stored:


> x <- 1619052826499
> print(x)
[1] 1.619053e+12
> dput(x)
1619052826499
> options(scipen=10)
> print(x)
[1] 1619052826499

-------------------------

David L Carlson

Anthropology Department

Texas A&M University

________________________________
From: R-help <[hidden email]> on behalf of Jeff Reichman <[hidden email]>
Sent: Sunday, October 14, 2018 8:45:17 PM
To: [hidden email]
Subject: [R] Scientific Notation

R Forum

Is there a way to tell R to not import numbers as scientific notation
(read.csv).  So that 1619052826499 will not be imported as 1.619053e+12.

Jeff Reichman

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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

Jeff Newmiller
While the OP should study up on what numeric values are, context may determine that a different storage mode be used. For example, if the values are intrinsically integers and meet the appropriate magnitude requirements, importing as integer may make sense. Or, if these are identifiers like serial numbers it may make sense to import as character data. To implement those constraints, read up on the colClasses argument to read.csv.

If these values really are intended for computation, the OP needs to differentiate how R prints values by default from how R can be made to export character representations of that internal data. In short, don't get picky about scientific notation until you export the data from R, because floating point data are ALWAYS in scientific notation (base 2) internally.

On October 14, 2018 6:58:05 PM PDT, David L Carlson <[hidden email]> wrote:

>You probably need to read up on the scipen= argument in ?options. What
>is displayed at the console is not what is stored:
>
>
>> x <- 1619052826499
>> print(x)
>[1] 1.619053e+12
>> dput(x)
>1619052826499
>> options(scipen=10)
>> print(x)
>[1] 1619052826499
>
>-------------------------
>
>David L Carlson
>
>Anthropology Department
>
>Texas A&M University
>
>________________________________
>From: R-help <[hidden email]> on behalf of Jeff Reichman
><[hidden email]>
>Sent: Sunday, October 14, 2018 8:45:17 PM
>To: [hidden email]
>Subject: [R] Scientific Notation
>
>R Forum
>
>Is there a way to tell R to not import numbers as scientific notation
>(read.csv).  So that 1619052826499 will not be imported as
>1.619053e+12.
>
>Jeff Reichman
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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.
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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

reichmaj
In reply to this post by David Carlson
Mr. Carlson

 

Well that was easy enough. Thank you.  

Options -
https://stat.ethz.ch/R-manual/R-devel/library/base/html/options.html

 

Jeff

 

From: David L Carlson <[hidden email]>
Sent: Sunday, October 14, 2018 8:58 PM
To: [hidden email]; [hidden email]
Subject: Re: [R] Scientific Notation

 

You probably need to read up on the scipen= argument in ?options. What is
displayed at the console is not what is stored:

 

> x <- 1619052826499

> print(x)

[1] 1.619053e+12

> dput(x)

1619052826499

> options(scipen=10)

> print(x)

[1] 1619052826499

 

-------------------------

David L Carlson

Anthropology Department

Texas A&M University

  _____  

From: R-help <[hidden email]
<mailto:[hidden email]> > on behalf of Jeff Reichman
<reichmanj@sbcglobalnet>
Sent: Sunday, October 14, 2018 8:45:17 PM
To: [hidden email] <mailto:[hidden email]>
Subject: [R] Scientific Notation

 

R Forum

Is there a way to tell R to not import numbers as scientific notation
(read.csv).  So that 1619052826499 will not be imported as 1.619053e+12.

Jeff Reichman

______________________________________________
[hidden email] <mailto:[hidden email]>  mailing list -- To
UNSUBSCRIBE and more, see
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.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.