[R] strange strsplit gsub problem 0 is this a bug or a string length limitation?
Marc Schwartz
marc_schwartz at me.com
Fri Jul 10 16:34:21 CEST 2009
On Jul 10, 2009, at 9:07 AM, tradenet wrote:
>
> Thanks Marc!
>
> I just found that the ~500 char limitation via an online search for
> the
> specs for the formula class
> The rmetrics library I'm using get's it's character array of assets by
> parsing a formula passed as an input parameter to the
> portfolioBacktest
> function. Can I copy the portfolioBacktest function from the
> source, call
> it portfolioBackest_hack, add an additional pamater, an array of asset
> names, and have my version use this argument instead of parsing the
> formula?
> I'm fairly new to R so I don't know if R will find my function and
> if my
> function will find the other fPortfolio functions that may be
> referenced by
> the original, non "_hack" version of the function.
>
> Warm regards,
>
> Andrew
Hi Andrew,
Happy to help.
In terms of your proposal as a short term fix, it may be possible to
do that. If you do create a new local function and call it directly,
it will be seen instead of the package default version of the same
function. However, without reviewing the code and package in detail,
you have to be careful about other function dependencies and namespace
issues that may be present. I would go ahead and try it to see it it
works.
A better and longer term approach would be to have the function
author(s) modify the way in which they manipulate the formula object.
They may wish to review this thread from 2001:
https://stat.ethz.ch/pipermail/r-help/2001-August/014628.html
Back then, the as.character() limit was 60 and was increased by Prof.
Ripley to 500 in response to that discussion.
However, in that thread, Prof. Ripley also proposes a better way of
manipulating the formula object passed to the function. That approach
uses deparse() rather than using as.character().
HTH,
Marc Schwartz
More information about the R-help
mailing list