I am currently writing a small package that is supposed to fit multinomial processing tree models (for not needed background info a web page and a pdf).
What it does is the following: It reads a model (i.e., formulas) from a file and converts them (via parse
) to expressions. Later, some of the variables in these expressions are exchanged by other variables from another file (i.e., model restrictions are applied). Therefore, the model is back transformed to characters (via as.character
) and the exchange is done via gsub
.
The problem: If a single expression is longer than 500 characters, transforming them back via as.character
truncates them to 500 characters (or so).
?as.character
gives:
as.character truncates components of language objects to 500 characters (was about 70 before 1.3.1).
Here an example:
text1 <- paste(rep(LETTERS, 10), collapse = " + ")
nchar(text1)
[1] 1037
expr1 <- parse(text = text1)
text2 <- as.character(expr1)
[1] 504
The question: Can you get around this 500 character limitation?
I know we could get around this problem if we would apply the restrictions (i.e., exchange the variables) before we parse the model the first time. But, this would involve a lot of programming, as the whole thing is basically ready, and it would be great if we could get around this 500 character limitations another way.
char s[500]
which seems lame. Perhaps there's a good reason.... – Gillead