[Rd] assign, documentation (PR#1434)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
04 Apr 2002 17:37:18 +0200


ripley@stats.ox.ac.uk writes:

> On Thu, 4 Apr 2002 Martin.Schlather@uni-bayreuth.de wrote:
> 
> > The help for `assign' says
> >
> >  In all the assignment operator expressions, `x' can be a name or
> >  an expression defining a part of an object to be replaced (e.g.,
> >  `z[[1]]').  The name does not need to be quoted, though it can be.
> >
> > So I would expect that by
> >  a<-1:4
> >  assign("a[1]",2)
> > the first component of a gets the value 2, but the object "a[1]" is
> > created.
> > Could this be clarified in the documentation?
> 
> Could you suggest how?  You quoted an *expression*, and the page refers to
> quoting a *name*, so I don't know that I see the crux here.

Actually, it *is* a name that is getting quoted, it just has these weird
bracket characters in it, so it is not "syntactically valid". 

One improvement might be: "the name can be any string of text and may
be quoted, but this is only necessary if it is not a syntactically
valid name."

We might also emphasize that "assignment operator expressions" does
not include assign(), only <-, <<-, and =. (And _ until we finally get
it killed...). On the other hand it is arguably clear enough already,
if read carefully. (For this reason alone, the posters remark is off
base, but he might have asked about "a[1]" <- 2.)

In assign(), `x' must be a character object. As in

> a <- "b"
> assign(a,2)
> a
[1] "b"
> b
[1] 2


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._