john.little at dunelm.org.uk
2006-May-24 13:11 UTC
[Rd] Problem with pasteing formulas (PR#8897)
Hi, If I create a formula with say 100 terms and then paste it: xnam <- paste("x", 1:100, sep="") fmla <- as.formula(paste("y ~ ", paste(xnam, collapse= "+"))) paste(fmla) The result seems to cut off everything after the first 500 characters and gives no warning message. I have the most recent version of R from the R website and the problem occurs on both Unix and Windows machines Thanks John -- John Little Department of Mathematical Sciences Durham University Durham UK
ripley at stats.ox.ac.uk
2006-May-24 13:29 UTC
[Rd] Problem with pasteing formulas (PR#8897)
See ?as.character (which paste effectively calls on non-character objects, as ?paste says): Note: 'as.character' truncates components of language objects to 500 characters (was about 70 before 1.3.1). so it is working as documented. Not then a bug. You can (and probably should) use a construct like that in terms.formula: else paste(deparse(form[[2]]), collapse = "") to convert a formula to a complete character string. On Wed, 24 May 2006, john.little at dunelm.org.uk wrote:> Hi, > If I create a formula with say 100 terms and then paste it: > > xnam <- paste("x", 1:100, sep="") > fmla <- as.formula(paste("y ~ ", paste(xnam, collapse= "+"))) > paste(fmla) > > The result seems to cut off everything after the first 500 characters > and gives no warning message. > > I have the most recent version of R from the R website and the problem > occurs on both Unix and Windows machines > > Thanks > > John >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595