Hi, I have a tiny question concerning .Options$max.print I have to set up this value to a greater value than 10000 because I want to concatenate my output of a function to one single string (for connivence). I did this via .Options$max.print <- 64000 or options(max.print=64000) Then I call out <- paste(out, blabla) several times, but nchar(out) is never larger than 10000. I read in the help about '.Options' that this is not yet used in base R. Could this be my problem? Thanks for any hint Hans BTW I believe, there is a typo within the help page about '.Options' ... The ?factory-fresh? default settings of some of these options are ... max.print 1000 ... This should be ... max.print 10000 ...
>>>>> "HansJB" == Hans-Joerg Bibiko <bibiko at eva.mpg.de> >>>>> on Mon, 14 Aug 2006 17:56:30 +0200 writes:HansJB> Hi, I have a tiny question concerning HansJB> .Options$max.print HansJB> I have to set up this value to a greater value than HansJB> 10000 because I want to concatenate my output of a HansJB> function to one single string (for connivence). HansJB> I did this via .Options$max.print <- 64000 or HansJB> options(max.print=64000) HansJB> Then I call out <- paste(out, blabla) several times, HansJB> but nchar(out) is never larger than 10000. HansJB> I read in the help about '.Options' that this is not HansJB> yet used in base R. Could this be my problem? well, it at least makes clear that your assumption that this option would influence your paste() must be wrong. I don't think there's any option influencing paste() and I hope there won't every be any. Options typically should only influence ``output formatting'' but not the result of a ``computational'' (i.e. non-printing/plotting) function. HansJB> Thanks for any hint The posting guide -- and every footer of all R-help posting asks for a small reproducible example of R code. So please do provide one [and, BTW, keep this thread on R-help; do not reply privately..] HansJB> Hans HansJB> BTW I believe, there is a typo within the help page HansJB> about '.Options' HansJB> ... The ?factory-fresh? default settings of some HansJB> of these options are ... max.print 1000 ... HansJB> This should be ... max.print 10000 ... Yes, thank you. Martin Maechler, ETH Zurich
Hans-Joerg Bibiko
2006-Aug-15 08:15 UTC
[R] Question on .Options$max.print - print/cat extremely long strings on a screen
Dear list members,
sorry for my incompleteness!
My problem is the following:
(R 2.3.1 on Mac OS X 10.4.7 RAM 1GByte using Mac GUI)
I have a function like this:
foo1 <- function()
{
out <- NULL
for(i in 1:10010) out <- paste(out, i, ". line\n",
sep="")
return(out)
}
a <- foo1()
Now I want to display 'a' on the screen:
cat(a)
This doesn't work. 'a' is displayed only until '830. line'
print(a)
The same, 'a' is displayed only until '\n754. line\n755'.
cat(a, file='test.txt') # OK
works fine. That means, internally 'a' is fine.
Then I tried this way:
foo2 <- function()
{
out <- NULL
for(i in 1:10010) out <- c(out, paste(i, ". line",
sep=""))
return(out)
}
a <- foo2()
With
cat(a,sep="\n")
I see the complete content of 'a'.
paste(a, collapse = "\n")
I only see 'a' until '\n754. line\n755'.
cat(paste(a, collapse ="\n"))
I only see 'a' until '830. line'.
cat(paste(a, collapse ="\n"),file='test.txt')
This is OK.
My question now is whether there is an option to specifiy the maximum
size of a string which is displayed on the screen (running R in a
GUI)? Or is this fixed?
I read the help page about '.Options' and I found a variable
'max.print' with the comment that is not yet used in basic R.
I don't know whether this variable is responsible for that. I
increased 'max.print' but nothing changed.
##########
If I try this code on a Windows XP machine with 756 MByte RAM R-GUI
says after executing
foo1 <- function()
{
out <- NULL
for(i in 1:10010) out <- paste(out, i, ". line\n",
sep="")
return(out)
}
a <- foo1()
cat(a)
...
7548. lineWarning message:
printing of extremely long output is truncated
At least Windows writes a warning message.
###########
If I start a R session without the R-GUI via Mac Terminal typing 'R'
a<-foo1()
cat(a)
everything works perfectly!!!
I know the issue of outputting long strings and the way to display
long strings via foo2() would be ok for me, but I spent some time to
figure out why my function foo1() didn't work. R, running in GUI on
Mac, don't give you a warning. Now I know that if I print a long
string at the Mac-GUI-console the missing final quote character is an
indicator for a truncated output on a Mac. Maybe it would be nice to
output a warning(?)
Cheers,
Hans
Dear all, My question is concerned to the kind how a function is called. Example A: > foo(1) Example B: > a <- foo(1) Is there any way for the function foo() to recognise whether the returned value of foo() is stored in a variable or not, i.e. to distinguish between Example A and B? Any comments are welcomed. Many thanks in advance Hans