R version 3.5.0 (2018-04-23) -- "Joy in Playing" Platform: x86_64-pc-linux-gnu (64-bit) options(digits=3) itemInfo <- structure(list("aaa" = c(1.39633732316667, 1.32598263816667, 1.11658324066667, 1.23651072616667, 1.05368679983333, 1.03100737383333, 0.9630728395, 0.7483865045, 0.620086646166667, 0.5411017985, 0.496397607833333, 0.459528044666667, 0.427877047833333, 0.402085979666667, 0.283161181233333, 0.236896277233333), "bbb" = c(6.22533860696667, 5.229736804, 4.94816041772833, 4.17020503255333, 4.00453781427167, 3.56058007398333, 3.0125202404, 2.23782358733333, 2.14863910661167, 1.90460903044777, 1.62001089796667, 1.56341257968151, 1.23618558850667, 1.10086688908262, 0.661981500639833, 0.47397754310745), "ccc" = c(0.5165911355, 0.462204707666667, NA, 0.219635924333333, 0.441863780833333, 0.361502865833333, NA, 0.596137946666667, NA, 0.226984771566667, NA, 0.360922661583333, 0.2145347068, 0.287756249483333, NA, NA ), "ddd" = c(5.77538400186667, 5.115877113, NA, 4.71294520316667, 4.25952652129833, 3.68879921863167, NA, 2.01942456211145, NA, 2.02032557108, NA, 1.3818108759571, 1.80436759778167, 1.20789851993367, NA, NA), "eee" = c(2.49725347166667, -2.67340172316667, NA, 5.64195206333333, 2.07633555233333, 2.548949539, NA, 0.465537272243167, NA, 2.34255027516667, NA, 0.5400824922975, 2.1935000655, 0.890007976866667, NA, NA)), row.names = c("skill", "predict", "waiting", "complex", "novelty", "creative", "evaluated", "body", "control", "stakes", "spont", "chatter", "present", "reward", "feedback", "goal"), class = "data.frame") itemInfo # examine column ddd When I try this, column ddd has 1 fewer digits than expected. See the attached screenshot. Why don't all the columns have the same number of digits displayed? -- Joshua N. Pritikin, Ph.D. Virginia Institute for Psychiatric and Behavioral Genetics Virginia Commonwealth University PO Box 980126 800 E Leigh St, Biotech One, Suite 1-133 Richmond, VA 23219 http://exuberant-island.surge.sh -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2018-05-30 11-29-49.png Type: image/png Size: 81110 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20180531/d36daa8a/attachment.png>
Hi Joshua, Because there are no values in column ddd less than 1. itemInfo[3,"ddd"]<-0.3645372 itemInfo aaa bbb ccc ddd eee skill 1.396 6.225 0.517 5.775 2.497 predict 1.326 5.230 0.462 5.116 -2.673 waiting 1.117 4.948 NA 0.365 NA complex 1.237 4.170 0.220 4.713 5.642 novelty 1.054 4.005 0.442 4.260 2.076 creative 1.031 3.561 0.362 3.689 2.549 evaluated 0.963 3.013 NA NA NA body 0.748 2.238 0.596 2.019 0.466 control 0.620 2.149 NA NA NA stakes 0.541 1.905 0.227 2.020 2.343 spont 0.496 1.620 NA NA NA chatter 0.460 1.563 0.361 1.382 0.540 present 0.428 1.236 0.215 1.804 2.194 reward 0.402 1.101 0.288 1.208 0.890 feedback 0.283 0.662 NA NA NA goal 0.237 0.474 NA NA NA digits specifies the number of significant digits ("It is a suggestion only"), so when at least one number is padded with a leading zero it affects the formatting of the other numbers in that column. I suspect that this is an esthetic consideration to line up the decimal points. Jim On Thu, May 31, 2018 at 11:18 AM, Joshua N Pritikin <jpritikin at pobox.com> wrote:> R version 3.5.0 (2018-04-23) -- "Joy in Playing" > Platform: x86_64-pc-linux-gnu (64-bit) > > options(digits=3) > > itemInfo <- structure(list("aaa" = c(1.39633732316667, 1.32598263816667, 1.11658324066667, 1.23651072616667, 1.05368679983333, 1.03100737383333, 0.9630728395, 0.7483865045, 0.620086646166667, 0.5411017985, 0.496397607833333, 0.459528044666667, 0.427877047833333, 0.402085979666667, 0.283161181233333, 0.236896277233333), "bbb" = c(6.22533860696667, 5.229736804, 4.94816041772833, 4.17020503255333, 4.00453781427167, 3.56058007398333, 3.0125202404, 2.23782358733333, 2.14863910661167, 1.90460903044777, 1.62001089796667, 1.56341257968151, 1.23618558850667, 1.10086688908262, 0.661981500639833, 0.47397754310745), "ccc" = c(0.5165911355, 0.462204707666667, NA, 0.219635924333333, 0.441863780833333, 0.361502865833333, NA, 0.596137946666667, NA, 0.226984771566667, NA, 0.360922661583333, 0.2145347068, 0.287756249483333, NA, NA ), "ddd" = c(5.77538400186667, 5.115877113, NA, 4.71294520316667, 4.25952652129833, 3.68879921863167, NA, 2.01942456211145, NA, 2.02032557108, NA, 1.3818108759571, 1.80436759778167, 1.20789851993367, NA, NA), "eee" = c(2.49725347166667, -2.67340172316667, NA, 5.64195206333333, 2.07633555233333, 2.548949539, NA, 0.465537272243167, NA, 2.34255027516667, NA, 0.5400824922975, 2.1935000655, 0.890007976866667, NA, NA)), row.names = c("skill", "predict", "waiting", "complex", "novelty", "creative", "evaluated", "body", "control", "stakes", "spont", "chatter", "present", "reward", "feedback", "goal"), class = "data.frame") > > itemInfo # examine column ddd > > When I try this, column ddd has 1 fewer digits than expected. See the > attached screenshot. > > Why don't all the columns have the same number of digits displayed? > > -- > Joshua N. Pritikin, Ph.D. > Virginia Institute for Psychiatric and Behavioral Genetics > Virginia Commonwealth University > PO Box 980126 > 800 E Leigh St, Biotech One, Suite 1-133 > Richmond, VA 23219 > http://exuberant-island.surge.sh > > ______________________________________________ > 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. >
On Thu, May 31, 2018 at 03:30:42PM +1000, Jim Lemon wrote:> Because there are no values in column ddd less than 1.Whoa! Thank you for pointing that out.
Well pointed out, Jim! It is infortunate that the documentation for options(digits=...) does not mention that these are *significant digits* and not *decimal places* (which is what Joshua seems to want): "?digits?: controls the number of digits to print when printing numeric values." On the face of it, printing the value "0,517" of 'ccc' looks like printing 4 digits! Joshua's could look even worse if 'ddd' had values in the 1000s! To achieve exactly what Joshua seems to want, use the round() function. Starting with his original assignment of values to the variable itemInfo, the result of round(itemInfo,digits=3) is: aaa bbb ccc ddd eee skill 1.396 6.225 0.517 5.775 2.497 predict 1.326 5.230 0.462 5.116 -2.673 waiting 1.117 4.948 NA NA NA complex 1.237 4.170 0.220 4.713 5.642 novelty 1.054 4.005 0.442 4.260 2.076 creative 1.031 3.561 0.362 3.689 2.549 evaluated 0.963 3.013 NA NA NA body 0.748 2.238 0.596 2.019 0.466 control 0.620 2.149 NA NA NA stakes 0.541 1.905 0.227 2.020 2.343 spont 0.496 1.620 NA NA NA chatter 0.460 1.563 0.361 1.382 0.540 present 0.428 1.236 0.215 1.804 2.194 reward 0.402 1.101 0.288 1.208 0.890 feedback 0.283 0.662 NA NA NA goal 0.237 0.474 NA NA NA Best wishes to all, Ted. On Thu, 2018-05-31 at 15:30 +1000, Jim Lemon wrote:> Hi Joshua, > Because there are no values in column ddd less than 1. > > itemInfo[3,"ddd"]<-0.3645372 > itemInfo > aaa bbb ccc ddd eee > skill 1.396 6.225 0.517 5.775 2.497 > predict 1.326 5.230 0.462 5.116 -2.673 > waiting 1.117 4.948 NA 0.365 NA > complex 1.237 4.170 0.220 4.713 5.642 > novelty 1.054 4.005 0.442 4.260 2.076 > creative 1.031 3.561 0.362 3.689 2.549 > evaluated 0.963 3.013 NA NA NA > body 0.748 2.238 0.596 2.019 0.466 > control 0.620 2.149 NA NA NA > stakes 0.541 1.905 0.227 2.020 2.343 > spont 0.496 1.620 NA NA NA > chatter 0.460 1.563 0.361 1.382 0.540 > present 0.428 1.236 0.215 1.804 2.194 > reward 0.402 1.101 0.288 1.208 0.890 > feedback 0.283 0.662 NA NA NA > goal 0.237 0.474 NA NA NA > > digits specifies the number of significant digits ("It is a suggestion > only"), so when at least one number is padded with a leading zero it > affects the formatting of the other numbers in that column. I suspect > that this is an esthetic consideration to line up the decimal points. > > Jim > > > On Thu, May 31, 2018 at 11:18 AM, Joshua N Pritikin <jpritikin at pobox.com> wrote: > > R version 3.5.0 (2018-04-23) -- "Joy in Playing" > > Platform: x86_64-pc-linux-gnu (64-bit) > > > > options(digits=3) > > > > itemInfo <- structure(list("aaa" = c(1.39633732316667, 1.32598263816667, 1.11658324066667, 1.23651072616667, 1.05368679983333, 1.03100737383333, 0.9630728395, 0.7483865045, 0.620086646166667, 0.5411017985, 0.496397607833333, 0.459528044666667, 0.427877047833333, 0.402085979666667, 0.283161181233333, 0.236896277233333), "bbb" = c(6.22533860696667, 5.229736804, 4.94816041772833, 4.17020503255333, 4.00453781427167, 3.56058007398333, 3.0125202404, 2.23782358733333, 2.14863910661167, 1.90460903044777, 1.62001089796667, 1.56341257968151, 1.23618558850667, 1.10086688908262, 0.661981500639833, 0.47397754310745), "ccc" = c(0.5165911355, 0.462204707666667, NA, 0.219635924333333, 0.441863780833333, 0.361502865833333, NA, 0.596137946666667, NA, 0.226984771566667, NA, 0.360922661583333, 0.2145347068, 0.287756249483333, NA, NA ), "ddd" = c(5.77538400186667, 5.115877113, NA, 4.71294520316667, 4.25952652129833, 3.68879921863167, NA, 2.01942456211145, NA, 2.02032557108, NA, 1.381810875 > 9571, 1.80436759778167, 1.20789851993367, NA, NA), "eee" = c(2.49725347166667, -2.67340172316667, NA, 5.64195206333333, 2.07633555233333, 2.548949539, NA, 0.465537272243167, NA, 2.34255027516667, NA, 0.5400824922975, 2.1935000655, 0.890007976866667, NA, NA)), row.names = c("skill", "predict", "waiting", "complex", "novelty", "creative", "evaluated", "body", "control", "stakes", "spont", "chatter", "present", "reward", "feedback", "goal"), class = "data.frame") > > > > itemInfo # examine column ddd > > > > When I try this, column ddd has 1 fewer digits than expected. See the > > attached screenshot. > > > > Why don't all the columns have the same number of digits displayed? > > > > -- > > Joshua N. Pritikin, Ph.D. > > Virginia Institute for Psychiatric and Behavioral Genetics > > Virginia Commonwealth University > > PO Box 980126 > > 800 E Leigh St, Biotech One, Suite 1-133 > > Richmond, VA 23219 > > http://exuberant-island.surge.sh > > > > ______________________________________________ > > 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. > > > > ______________________________________________ > 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.