Re: [R] String buffer

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Tue, 20 May 2008 13:29:40 -0400

On 5/20/2008 12:58 PM, Applejus wrote:
> Hello,
>
> I have an expression "a" in R that has about 2300 characters and I want to
> convert it to a string using toString or as.character. The problem is I am
> only getting the first 500 or so characters when I convert it to string. I
> tried to use substring in order to convert one bunch at a time, but when I
> type substring(a, 498, 1000) I get only 2 characters, meaning it seems there
> is a limit of 500 characters at most, even for the substring function.

When you deparse a long expression, it comes back as a multi-element character vector. as.character() only returns the first element. You can get all of them by calling deparse() directly, and then perhaps you'll want to paste them together.

I'm not sure if this is a bug in as.character, or just an undocumented limitation.

>
> The weird part is that the conversion with as.character works fine with
> Splus, but not in R.

I wouldn't call it "weird"; there are lots of differences between the two programs. They have been developed independently.

Duncan Murdoch

>
> Could anyone help me out? Is there a string buffer function like that of
> java? Should I change something in the console configuration? (I tried to
> increase the buffer but it still doesn't work)
>
> Thanks!



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. Received on Tue 20 May 2008 - 17:54:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 19:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive