Dear Marin, May be not the cleanest way to do it, but the following seems to work:
write.table(as.character(round(pi, 10)), "pi.txt", row.names = FALSE, col.names = FALSE, quote = FALSE) Best, Jorge.- On Fri, Mar 8, 2013 at 11:24 AM, Marino David <davidmarino...@gmail.com>wrote: > Hi Bert, > > I read both options and write.table help, but I still can't make it to save > the data into txt file with fixed precision. > > To let you know more clearly what I want, I still you use the previous > simple example to illustrate. > > I want to save pi into pi.txt file with 10 decimal places, that > is 3.1415926536. How to do it? > > > > Thanks > > Marin > > > > 2013/3/8 Marino David <davidmarino...@gmail.com> > > > Hi Bert, > > > > I want to save the data into .txt file for another software process. > > > > Thanks for suggestion. > > > > 2013/3/8 Bert Gunter <gunter.ber...@gene.com> > > > >> ?write.table > >> > >> which says, under details: > >> > >> "In almost all cases the conversion of numeric quantities is governed > >> by the option "scipen" (see options), but with the internal equivalent > >> of digits=15. For finer control, use format to make a character > >> matrix/data frame, and call write.table on that. " > >> > >> Not sure if this is what you want, as "export" is rather vague. > >> > >> -- Bert > >> > >> On Thu, Mar 7, 2013 at 12:52 PM, Marino David <davidmarino...@gmail.com > > > >> wrote: > >> > Hi all mailing listers, > >> > > >> > I want to export data with specified precision into .txt file. How > can I > >> > make it? See below > >> > > >> > sprintf("%.10f",pi) > >> > [1] "3.1415926536" > >> > > >> > when carry out write.matrix(pi,"pi.txt"), 3.141592653589793115998 in > >> pi.txt > >> > file not with 10 decimal places like using sprintf("%.10f",pi) > >> > > >> > > >> > Thanks > >> > > >> > Marino > >> > > >> > [[alternative HTML version deleted]] > >> > > >> > ______________________________________________ > >> > 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< > http://www.r-project.org/posting-guide.html> > >> > and provide commented, minimal, self-contained, reproducible code. > >> > >> > >> > >> -- > >> > >> Bert Gunter > >> Genentech Nonclinical Biostatistics > >> > >> Internal Contact Info: > >> Phone: 467-7374 > >> Website: > >> > >> > http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm > >> > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.