This may have been asked before, but I don't understand the behavior of options(digits = 1) for vectors containing values such as 0.01 For example, why is this happening: options(digits = 1)> 0.01[1] 0.01 More examples:> options(digits = 7) > 0.1[1] 0.1> 0.01[1] 0.01> 0.11[1] 0.11> c(0.1,0.01)[1] 0.10 0.01> options(digits = 1) > 0.1[1] 0.1> 0.01[1] 0.01> 0.11[1] 0.1> c(0.1,0.01)[1] 0.10 0.01>The help file in ?options says: digits: controls the number of digits to print when printing numeric values. It is a suggestion only. Is this what is mean by "It is a suggestion only." ? [[alternative HTML version deleted]]
Hi, Tal, in print.default it says: digits: a non-null value for digits specifies the __minimum__ number of __significant__ digits to be printed in values. Maybe this clarifies your observation. Hth -- Gerrit --------------------------------------------------------------------- Dr. Gerrit Eichner Mathematical Institute, Room 212 gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/eichner --------------------------------------------------------------------- Am 21.03.2017 um 10:30 schrieb Tal Galili:> This may have been asked before, but I don't understand the behavior > of options(digits = 1) for vectors containing values such as 0.01 > > For example, why is this happening: > options(digits = 1) >> 0.01 > [1] 0.01 > > > More examples: >> options(digits = 7) >> 0.1 > [1] 0.1 >> 0.01 > [1] 0.01 >> 0.11 > [1] 0.11 >> c(0.1,0.01) > [1] 0.10 0.01 >> options(digits = 1) >> 0.1 > [1] 0.1 >> 0.01 > [1] 0.01 >> 0.11 > [1] 0.1 >> c(0.1,0.01) > [1] 0.10 0.01 >> > > The help file in ?options says: > digits: > controls the number of digits to print when printing numeric values. It is > a suggestion only. > > > Is this what is mean by "It is a suggestion only." ? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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. >
I'd say it's about equivalent to suggesting to Vladimir Putin that he stop trying to take over territories bordering Russia. Jim On Tue, Mar 21, 2017 at 8:30 PM, Tal Galili <tal.galili at gmail.com> wrote:> This may have been asked before, but I don't understand the behavior > of options(digits = 1) for vectors containing values such as 0.01 > > For example, why is this happening: > options(digits = 1) >> 0.01 > [1] 0.01 > > > More examples: >> options(digits = 7) >> 0.1 > [1] 0.1 >> 0.01 > [1] 0.01 >> 0.11 > [1] 0.11 >> c(0.1,0.01) > [1] 0.10 0.01 >> options(digits = 1) >> 0.1 > [1] 0.1 >> 0.01 > [1] 0.01 >> 0.11 > [1] 0.1 >> c(0.1,0.01) > [1] 0.10 0.01 >> > > The help file in ?options says: > digits: > controls the number of digits to print when printing numeric values. It is > a suggestion only. > > > Is this what is mean by "It is a suggestion only." ? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.
>>>>> Gerrit Eichner <Gerrit.Eichner at math.uni-giessen.de> >>>>> on Tue, 21 Mar 2017 10:45:13 +0100 writes:> Hi, Tal, > in print.default it says: > digits: > a non-null value for digits specifies the __minimum__ > number of __significant__ digits to be printed in values. > Maybe this clarifies your observation. > Hth -- Gerrit I hope too, thank you Gerrit. It seems that many people do not understand the term "number of significant digits". I think you can learn about it by studying (the help page and examples of) signif(x, digits) and maybe compare with round (x, digits). > Am 21.03.2017 um 10:30 schrieb Tal Galili: >> This may have been asked before, but I don't understand the behavior >> of options(digits = 1) for vectors containing values such as 0.01 >> >> For example, why is this happening: >> options(digits = 1) >>> 0.01 >> [1] 0.01 >> >> >> More examples: >>> options(digits = 7) >>> 0.1 >> [1] 0.1 >>> 0.01 >> [1] 0.01 >>> 0.11 >> [1] 0.11 >>> c(0.1,0.01) >> [1] 0.10 0.01 >>> options(digits = 1) >>> 0.1 >> [1] 0.1 >>> 0.01 >> [1] 0.01 >>> 0.11 >> [1] 0.1 >>> c(0.1,0.01) >> [1] 0.10 0.01 >>> >> >> The help file in ?options says: >> digits: >> controls the number of digits to print when printing numeric values. It is >> a suggestion only. >> >> >> Is this what is mean by "It is a suggestion only." ?