[Rd] Smal problem with porting code to S-PLUS (PR#871)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Thu, 8 Mar 2001 17:45:58 +0100 (MET)


> From: harald.fekjar@basalmed.uio.no
> Date: Thu, 8 Mar 2001 16:29:55 +0100 (MET)
> 
> Full_Name: Harald Fekjær
> Version: 1.22
> OS: Windows 
> Submission from: (NULL) (158.36.132.220)
> 
> 
> Dear R developers
> 
> Actually, this is not a bug, but a small remark about a way R is working that
> makes trouble in porting the code to S.

It *is* a bug: see later.

> If I run the following i R:
> ---
> midl <- 4
> attr(midl,"Object created") <- date()
> dump("midl","midl.R")
> ---
> 
> I get a file like:
> ---
> "midl" <-
> structure(4, Object created = "Thu Mar 08 16:04:04 2001")
> ---
> 
> This works well inside R, but S-PLUS has trouble reading it, because S needs "
> around a attribute with spaces. E.g. S-PLUS wants:

My version of R can't read that either.  Did you try it in R?
> source("midl.R")
Error in parse(file, n, text, prompt) : syntax error on line 2

Similarly,

> deparse(midl)
[1] "structure(4, Object created = \"Thu Mar  8 16:24:16 2001\")"

cannot be re-parsed.

> ---
> "midl" <-
> structure(4, "Object created" = "Thu Mar 08 16:04:04 2001")
> ---
> 
> This last example reads well into both systems, so way not let R print out the
> attributes names with "..."

Yes, it should do.  However, the code (in deparse.c) is pretty complicated
and used recursively.  I think I have a solution ... still testing.

Meanwhile, avoid attributes with non-standard S names.

-- 
Brian D. Ripley,                  ripley@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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._