Skip to content

Bug in as.character? (PR#14206)

2 messages · Havard Rue, Peter Dalgaard

#
A long formula which is converted using as.character, looses its last
part: ``diagonal = 1e-12)'' 

Shorter formula is ok though.

Best,
H??vard

************

Browse[2]> formula.str
y ~ -1 + b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8 + b9 + b10 + b11 + 
    b12 + b13 + b14 + b15 + b16 + b17 + b18 + b19 + b20 + b21 + 
    b22 + b23 + b24 + b25 + b26 + b27 + b28 + b29 + b30 + b31 + 
    b32 + b33 + b34 + b35 + b36 + b37 + b38 + b39 + b40 + b41 + 
    b42 + b43 + b44 + b45 + b46 + b47 + b48 + b49 + elevation + 
    f(idx, model = "sphere", sphere.dir = "global_temperature_80s", 
        T.order = 2, K.order = 2, T.model = "rotsym", K.model =
"rotsym", 
        initial = c(-4, 1, 0), param = c(-4, 0.01, 3, 0.01, 0, 
            1), replicate = replicate, diagonal = 1e-12)

Browse[2]> formula.str[3]
-1 + b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8 + b9 + b10 + b11 + 
    b12 + b13 + b14 + b15 + b16 + b17 + b18 + b19 + b20 + b21 + 
    b22 + b23 + b24 + b25 + b26 + b27 + b28 + b29 + b30 + b31 + 
    b32 + b33 + b34 + b35 + b36 + b37 + b38 + b39 + b40 + b41 + 
    b42 + b43 + b44 + b45 + b46 + b47 + b48 + b49 + elevation + 
    f(idx, model = "sphere", sphere.dir = "global_temperature_80s", 
        T.order = 2, K.order = 2, T.model = "rotsym", K.model =
"rotsym", 
        initial = c(-4, 1, 0), param = c(-4, 0.01, 3, 0.01, 0, 
            1), replicate = replicate, diagonal = 1e-12)()

Browse[2]> as.character(formula.str[3])
[1] "-1 + b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8 + b9 + b10 + b11 + b12 +
b13 + b14 + b15 + b16 + b17 + b18 + b19 + b20 + b21 + b22 + b23 + b24 +
b25 + b26 + b27 + b28 + b29 + b30 + b31 + b32 + b33 + b34 + b35 + b36 +
b37 + b38 + b39 + b40 + b41 + b42 + b43 + b44 + b45 + b46 + b47 + b48 +
b49 + elevation + f(idx, model = \"sphere\", sphere.dir =
\"global_temperature_80s\", T.order = 2, K.order = 2, T.model = \"rotsym
\", K.model = \"rotsym\", initial = c(-4, 1, 0), param = c(-4, 0.01, 3,
0.01, 0, 1), replicate = replicate, "



--please do not edit the information below--

Version:
 platform = x86_64-redhat-linux-gnu
 arch = x86_64
 os = linux-gnu
 system = x86_64, linux-gnu
 status = 
 major = 2
 minor = 10.1
 year = 2009
 month = 12
 day = 14
 svn rev = 50720
 language = R
 version.string = R version 2.10.1 (2009-12-14)

Locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_DK.utf8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

Search Path:
 .GlobalEnv, package:stats, package:graphics, package:grDevices,
package:datasets, package:INLA, package:R.utils, package:R.oo,
package:utils, package:R.methodsS3, package:methods, Autoloads,
package:base
#
Havard.Rue at math.ntnu.no wrote:
(If you have to put a ? in a bug report, ask instead!)

This is entirely consistent with  help(as.character):

Note:

     ?as.character? truncates components of language objects to 500
     characters (was about 70 before 1.3.1).


If you insist on working with very long formulas in their character
representation, you need to use deparse() and deal with the resulting
multi-line character vectors. (I can't tell what you're trying to do,
but update.formula() may provide a cleaner way of modifying formulas.)