HJ YAN
2012-Aug-06 16:14 UTC
[R] How to convert data to 'normal' if they are in the form of standard scientific notations?
Dear R users I read two csv data files into R and called them Tem1 and Tem5. For the first column, data in Tem1 has 13 digits where in Tem5 there are 14 digits for each observation. Originally there are 'numerical' as can be seen in my code below. But how can I display/convert them using other form rather than scientific notations which seems a standard/default? I want them to be in the form like '20110911001084', but I'm very confused why when I used 'as.factor' call it works for my 'Tem1' but not for 'Tem5'...?? Many thanks! HJ> Tem1[1:5,1][1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12> Tem5[1:5,1][1] 2.011091e+13 2.011091e+13 2.011091e+13 2.011091e+13 2.011091e+13> class(Tem1[1:5,1])[1] "numeric"> class(Tem5[1:5,1])[1] "numeric"> as.factor(Tem1[1:5,1])[1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12Levels: 2.10004e+12> as.factor(Tem5[1:5,1])[1] 20110911001084 20110911001084 20110911001084 20110911001084 20110911001084 Levels: 20110911001084 [[alternative HTML version deleted]]
Jean V Adams
2012-Aug-06 18:04 UTC
[R] How to convert data to 'normal' if they are in the form of standard scientific notations?
HJ, You don't provide any reproducible code, so I had to make up my own. dat <- data.frame(a=letters[1:5], x=c(20110911001084, 20110911001084, 20110911001084, 20110911001084, 20110911001084), y=c(2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12)) In my example, the long numbers print out without scientific notation. dat a x y 1 a 20110911001084 2100040000000 2 b 20110911001084 2100040000000 3 c 20110911001084 2100040000000 4 d 20110911001084 2100040000000 5 e 20110911001084 2100040000000 I can make it print with scientific notation using the digits argument to the print() function. print(dat, digits=3) a x y 1 a 2.01e+13 2.1e+12 2 b 2.01e+13 2.1e+12 3 c 2.01e+13 2.1e+12 4 d 2.01e+13 2.1e+12 5 e 2.01e+13 2.1e+12 What is your default number of digits? getOption("digits") Jean HJ YAN <yhj204@googlemail.com> wrote on 08/06/2012 11:14:17 AM:> > Dear R users > > I read two csv data files into R and called them Tem1 and Tem5. > > For the first column, data in Tem1 has 13 digits where in Tem5 there are14> digits for each observation. > > Originally there are 'numerical' as can be seen in my code below. Buthow> can I display/convert them using other form rather than scientific > notations which seems a standard/default? > > I want them to be in the form like '20110911001084', but I'm veryconfused> why when I used 'as.factor' call it works for my 'Tem1' but not for > 'Tem5'...?? > > > Many thanks! > > HJ > > > Tem1[1:5,1][1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2. > 10004e+12> Tem5[1:5,1][1] 2.011091e+13 2.011091e+13 2.011091e+13 2. > 011091e+13 2.011091e+13> class(Tem1[1:5,1])[1] "numeric"> class(Tem5 > [1:5,1])[1] "numeric"> as.factor(Tem1[1:5,1])[1] 2.10004e+12 2. > 10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 > Levels: 2.10004e+12> as.factor(Tem5[1:5,1])[1] 20110911001084 > 20110911001084 20110911001084 20110911001084 20110911001084 > Levels: 20110911001084[[alternative HTML version deleted]]
Reasonably Related Threads
- How to combine conditional argument and logical argument in R to create subset of data...
- load data with scientific notations
- [Bug 2747] New: Different notations for the same IP-address result in multiple entries in known_hosts
- [Bug 1444] New: nftables-0.9.6 crashes on some set notations:
- [PATCH] nouveau: Switch perms from macros to octal notations, module params readable to everyone