[R-SIG-Mac] Question on .Options$max.print - print/cat extremely long strings on a screen

Hans-Joerg Bibiko bibiko at eva.mpg.de
Tue Aug 15 11:26:09 CEST 2006


Dear list members,



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



More information about the R-SIG-Mac mailing list