Re: [R] write.table -- maintain decimal places

From: Jim Moon <moonja_at_ohsu.edu>
Date: Tue, 25 Jan 2011 17:22:33 -0800

Thank you for the response, Peter.

The approach:
write.table(format(df, drop0trailing=FALSE),file='df.txt',quote=F,sep='\t',row.names=F) surprisingly still results in some loss of trailing 0's.

df:

   EFFECT2 PVALUE
1 0.023 0.88080
2 -0.260 0.08641
3 -0.114 0.45200

df.txt:
EFFECT2 PVALUE

0.023      8.808e-01
-0.26      8.641e-02
-0.114     4.520e-01


-----Original Message-----
From: Peter Ehlers [mailto:ehlers_at_ucalgary.ca] Sent: Tuesday, January 25, 2011 5:09 PM
To: Jim Moon
Cc: r-help_at_r-project.org
Subject: Re: [R] write.table -- maintain decimal places

On 2011-01-25 16:16, Jim Moon wrote:
> Hello, All,
>
> How can I maintain the decimal places when using write.table()?
>
> Jim
>
> e.g.
>
> df:
> EFFECT2 PVALUE
> 1 0.023 0.88080
> 2 -0.260 0.08641
> 3 -0.114 0.45200
>
> write.table(df,file='df.txt',quote=F,sep='\t',row.names=F)

  write.table(format(df, drop0trailing=FALSE), ....)

Peter Ehlers

>
>
> df.txt:
> EFFECT2 PVALUE
> 0.023 0.8808
> -0.26 0.08641
> -0.114 0.452
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



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. Received on Wed 26 Jan 2011 - 01:25:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 26 Jan 2011 - 03:50:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive