Dominic Comtois
2014-May-16 20:41 UTC
[Rd] Inconsistency in vector printing depending on length
Consider the following:> 20:28[1] 20 21 22 23 24 25 26 27 28> 20:29 [1] 20 21 22 23 24 25 26 27 28 29It seems that when a vector has 10 elements, it prints out differently than one with 9 (extra space before the opening bracket). I can't see why this is happening. I am writing a manual containing many examples and the misalignment of the [1]'s is visually problematic. For additional considerations, please see my stackoverflow post: http://stackoverflow.com/questions/23703126/fixing-inconsistent-spacing-after-in-output-of-knitted-document/ R version: 3.1.0 Regards, Dominic Comtois [[alternative HTML version deleted]]
William Dunlap
2014-May-16 20:58 UTC
[Rd] Inconsistency in vector printing depending on length
> It seems that when a vector has 10 elements, it prints out differently than > one with 9 (extra space before the opening bracket). I can't see why this > is happening.It is happening because the print routine wants to be ready to print all the line-beginning [index] tags aligned with each other. With every power of ten in length it will need an extra space. I guess that when it does this it doesn't check whether it will need to make an [index] tag for the tail end of the vector. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, May 16, 2014 at 1:41 PM, Dominic Comtois <dominic.comtois at gmail.com> wrote:> Consider the following: > >> 20:28[1] 20 21 22 23 24 25 26 27 28> 20:29 [1] 20 21 22 23 24 25 26 27 28 29 > > > It seems that when a vector has 10 elements, it prints out differently than > one with 9 (extra space before the opening bracket). I can't see why this > is happening. I am writing a manual containing many examples and the > misalignment of the [1]'s is visually problematic. > > For additional considerations, please see my stackoverflow post: > http://stackoverflow.com/questions/23703126/fixing-inconsistent-spacing-after-in-output-of-knitted-document/ > > R version: 3.1.0 > > Regards, > > Dominic Comtois > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Lorenz, David
2014-May-16 21:05 UTC
[Rd] Inconsistency in vector printing depending on length
Dominic, Actually it makes perfect sense. When R prints vectors of length less than 9, it does not ever need to print 2 digits for the index. For lengths between 10 and 99, it may need to print an index with 2 digits, therefore, it prints the first index and all single digit indexes with a leading space. Continue the logic for number between 100 and 999 and so forth. This logic produces consistent looking rows. Dave On Fri, May 16, 2014 at 3:41 PM, Dominic Comtois <dominic.comtois@gmail.com>wrote:> Consider the following: > > > 20:28[1] 20 21 22 23 24 25 26 27 28> 20:29 [1] 20 21 22 23 24 25 26 27 > 28 29 > > > It seems that when a vector has 10 elements, it prints out differently than > one with 9 (extra space before the opening bracket). I can't see why this > is happening. I am writing a manual containing many examples and the > misalignment of the [1]'s is visually problematic. > > For additional considerations, please see my stackoverflow post: > > http://stackoverflow.com/questions/23703126/fixing-inconsistent-spacing-after-in-output-of-knitted-document/ > > R version: 3.1.0 > > Regards, > > Dominic Comtois > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]
Maybe Matching Threads
- Start smbd and nmbd daemons on other HP Unix (version 10.20) serv er
- Sensitivity analysis - looking a tool for epidemiologic research
- Two Lines, Two Businesses
- SAS Import with sas.get {Hmisc} - status 127 error
- capabilities(), was [R-pkg-devel] ... No protocol specified (OS X only)