Skip to content

problem with toString

2 messages · Tobias Elze, Brian Ripley

#
Hi,

I am using R 1.5.1 under Windows 2000. I have a problem with the function toString: It seems not to work for longer 
vectors as expressions.

This example works well:

q1<-expression(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15))
toString(q1)

I get:
"c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)"  => OK


But this one does not:
q2<-expression(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19))
toString(q2)

I get:
"c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, "  => WRONG

R cuts my vectors if they are too long. Can someone help me about this?

Thank you,

Tobias Elze.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Why are you using toString?  The main purpose of toString is to
get truncate the character representation of objects: otherwise
as.character would suffice.

The problem you are seeing is in as.character:
[1] "c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, "

and it comes from the cutoff value of 60 in deparse.  I would use

tmp <- deparse(q2, 500)
substring(tmp, 12, nchar(tmp)-1)
On Fri, 30 Aug 2002, Tobias Elze wrote:

            
function toString: It seems not to work for longer