Re: [R] stop R from rounding

2011-10-21 Thread Martin Maechler
 David Winsemius dwinsem...@comcast.net
 on Thu, 20 Oct 2011 01:51:28 -0400 writes:

 On Oct 19, 2011, at 11:29 PM, Alyse wrote:

 Hello,
 
 I have a column in a data frame that need to be 10 digits long.  As  
 such:
 
 Decimal.Year
 1  1994.25997
 2  1994.26020
 
 However, R keeps rounding the digits.  As such:
 
 Decimal.Year
 1  1994.260
 2  1994.260
 
 *Is there any way to stop this from happening?*
 
 Here is how I created the data frame:
 
 x - read.table('bats_1994_CTD.txt')
 colnames(x) -
 c 
 ('Cruise 
 ','Dec.Year','Lat.N','Long.W','Press','Depth','Temp','Sal','Oxy')
 date - subset(x,select=c(Dec.Year), (Depth201)  (Depth199))
 datelist - list(date$Dec.Year)
 temp - subset(x,select=c(Temp), (Depth201)  (Depth199))
 tempmean - aggregate(temp,by=datelist,FUN=mean)
 tempframe - data.frame(tempmean) #the first column of this  
 dataframe is the
 one that I don't want R to round

 R is not rounding. It is displaying with less than full precision. You  
 can control that with format or sprintf or formatC.

Well, or more simply in such situations by

  options(digits = 10) # if it's  10 (significant) digits you want
   # uses 10 (sig..) digits *FROM NOW ON*
   
or, if it's just for this one printing,
instead of saying
  
x

which is *equivalent* to  print(x), use

   print(x, digits = 10)

__
R-help@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.


Re: [R] stop R from rounding

2011-10-19 Thread David Winsemius


On Oct 19, 2011, at 11:29 PM, Alyse wrote:


Hello,

I have a column in a data frame that need to be 10 digits long.  As  
such:


Decimal.Year
1  1994.25997
2  1994.26020

However, R keeps rounding the digits.  As such:

   Decimal.Year
1  1994.260
2  1994.260

*Is there any way to stop this from happening?*

Here is how I created the data frame:

x - read.table('bats_1994_CTD.txt')
colnames(x) -
c 
('Cruise 
','Dec.Year','Lat.N','Long.W','Press','Depth','Temp','Sal','Oxy')

date - subset(x,select=c(Dec.Year), (Depth201)  (Depth199))
datelist - list(date$Dec.Year)
temp - subset(x,select=c(Temp), (Depth201)  (Depth199))
tempmean - aggregate(temp,by=datelist,FUN=mean)
tempframe - data.frame(tempmean) #the first column of this  
dataframe is the

one that I don't want R to round


R is not rounding. It is displaying with less than full precision. You  
can control that with format or sprintf or formatC.


Thank you!

--
View this message in context: 
http://r.789695.n4.nabble.com/stop-R-from-rounding-tp3920803p3920803.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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
West Hartford, CT

__
R-help@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.