[R] Printing left-justified character strings
zListserv
z||@t@erv @end|ng |rom gm@||@com
Wed Jun 6 12:28:54 CEST 2018
Sorry. Here's how I re-defined print, print.default, and print.data.frame:
print = function(df, ..., right=FALSE, row.names=FALSE) base::print(df, ..., right=right, row.names=row.names)
print.default = function(df, ..., right=FALSE, row.names=FALSE) base::print.default(df, ..., right=right, row.names=row.names)
print.data.frame = function(df, ..., right=FALSE, row.names=FALSE) base::print.data.frame(df, ..., right=right, row.names=row.names)
and this is what it yields (I would like it to print without row names and with text left-adjusted):
R> x <- as.data.frame(rep(c("a", "ab", "abc"), 7))
R> print(x)
rep(c("a", "ab", "abc"), 7)
a
ab
abc
a
ab
abc
a
ab
abc
a
ab
abc
a
ab
abc
a
ab
abc
a
ab
abc
R> head(x)
rep(c("a", "ab", "abc"), 7)
1 a
2 ab
3 abc
4 a
5 ab
6 abc
R> x
rep(c("a", "ab", "abc"), 7)
1 a
2 ab
3 abc
4 a
5 ab
6 abc
7 a
8 ab
9 abc
10 a
11 ab
12 abc
13 a
14 ab
15 abc
16 a
17 ab
18 abc
19 a
20 ab
21 abc
> On 2018-06-05, at 20:16, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
>
> On 05/06/2018 7:49 PM, zListserv wrote:
>> p.s. It seems to work for print command, but not for head, tail, or printing a data frame, per below. Any way fix the others so they all left-justify?
>
> You haven't shown us what you did.
>
> Duncan Murdoch
More information about the R-help
mailing list