[R] Console output

Peter Ehlers ehlers at ucalgary.ca
Mon Feb 21 14:55:24 CET 2011


On 2011-02-21 04:21, Antje Niederlein wrote:
> Thanks for every helpful answer :-) !
> I thought it was something "easier" but as long as there is a solution
> it's fine for me.
>
> Ciao,
> Antje

Here's one more that I use:

cat( 1:10, sep="\n" )

But this won't give you the row numbers.
[I keep a function around:
   cat1 <- function(x) cat(x, sep="\n")
]

I often use Ted's suggestion but you don't need the NULL:

  cbind(1:10)

will do.
I wasn't aware of Martin's clever idea.

Peter Ehlers

>
>
>
> On 21 February 2011 13:12, Martin Maechler<maechler at stat.math.ethz.ch>  wrote:
>>>>>>> Ted Harding<ted.harding at wlandres.net>
>>>>>>>      on Mon, 21 Feb 2011 11:08:19 -0000 (GMT) writes:
>>
>>     >  That doesn't produce quite what Antje asked for (since each
>>     >  line gets number "[1]"). The following does work:
>>
>>     >  print(cbind(NULL,(1:10)))
>>     >  [,1]
>>     >  [1,]    1
>>     >  [2,]    2
>>     >  [3,]    3
>>     >  [4,]    4
>>     >  [5,]    5
>>     >  [6,]    6
>>     >  [7,]    7
>>     >  [8,]    8
>>     >  [9,]    9
>>     >  [10,]   10
>>
>>     >  (apart from the unwanted column-name "[,1]", and the "," in
>>     >  rows).
>>
>> In principle, there would be "a true" solution,
>> but as you see, it's not quite possibly (by that means):
>>
>>> op<- options(width=7)
>> Error in options(width = 7) :
>>   invalid 'width' parameter, allowed 10...10000
>>> op<- options(width=10)
>>> 1:10
>>   [1]  1  2
>>   [3]  3  4
>>   [5]  5  6
>>   [7]  7  8
>>   [9]  9 10
>>> 1000+ 0:9 ## works for these
>>   [1] 1000
>>   [2] 1001
>>   [3] 1002
>>   [4] 1003
>>   [5] 1004
>>   [6] 1005
>>   [7] 1006
>>   [8] 1007
>>   [9] 1008
>> [10] 1009
>>>
>>
>> ---
>>
>> In principle, the lower bound (10) for the width option could be
>> lowered a bit more, as I think 10 had been a somewhat arbitrary
>> choice protecting useRs from hanging themselves..
>>
>> Martin
>>
>>
>>     >  Ted.
>>
>>     >  On 21-Feb-11 10:30:37, Yves REECHT wrote:
>>     >>  Hi,
>>     >>  You may try
>>     >>
>>     >>  invisible(sapply(1:10, print))
>>     >>
>>     >>  Yves
>>     >>
>>     >>
>>     >>  Le 21/02/2011 11:21, Antje Niederlein a écrit :
>>     >>>  Hi there,
>>     >>>
>>     >>>  I though there has been a possibility to force the output on
>>     >>>  the console with one element per line. Instead of this:
>>     >>>
>>     >>>>  1:10
>>     >>>  [1]  1  2  3  4  5  6  7  8  9 10
>>     >>>
>>     >>>  something like this
>>     >>>
>>     >>>>  1:10
>>     >>>  [1]   1
>>     >>>  [2]   2
>>     >>>  [3]   3
>>     >>>  [4]   4
>>     >>>  [5]   5
>>     >>>  [6]   6
>>     >>>  [7]   7
>>     >>>  [8]   8
>>     >>>  [9]   9
>>     >>>  [10]   10
>>     >>>
>>     >>>  Can anybody help?
>>     >>>  Antje
>>
>>     >  --------------------------------------------------------------------
>>     >  E-Mail: (Ted Harding)<ted.harding at wlandres.net>  Fax-to-email:
>>     >  +44 (0)870 094 0861 Date: 21-Feb-11 Time: 11:08:17
>>     >  ------------------------------ XFMail
>>     >  ------------------------------
>>
>>     >  ______________________________________________
>>     >  R-help at r-project.org mailing list
>>     >  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
>> 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
> 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.



More information about the R-help mailing list