Skip to content
Prev 374911 / 398498 Next

Printing left-justified character strings

On 05/06/2018 10:24 AM, zListserv wrote:
Could you be more specific?  I see character strings left justified, 
e.g. x <- rep(c("a", "ab", "abc"), 7) prints as

   [1] "a"   "ab"  "abc" "a"   "ab"  "abc" "a"
   [8] "ab"  "abc" "a"   "ab"  "abc" "a"   "ab"
  [15] "abc" "a"   "ab"  "abc" "a"   "ab"  "abc"

In a data frame, I do see it right justified:

      x
1    a
2   ab
3  abc
etc.

It is easy to change the printing of data frames:

print.data.frame <- function(x, ..., right = FALSE) {
   base::print.data.frame(x, ..., right = right)
}

 > data.frame(x)
    x
1  a
2  ab
3  abc

Are there other examples you're seeing?

Duncan Murdoch