R-alpha: Re: R/R-minus incompatibility [ an old one ]

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Mon, 10 Nov 1997 17:00:56 +0100

>>>>> "FrL" == Friedrich Leisch <Friedrich.Leisch@ci.tuwien.ac.at> writes:

    FrL> Hmm, I'm quite perplexed by something very trivial/stupid/whatever
    FrL> ...  don't know, if this one has been reported before:

    R> x<-1 x[1:2]
    FrL> Error: subscript out of bounds

    Splus> x<-1 x[1:2]
    FrL> [1] 1 NA

    FrL> Or is there an option to control this behaviour?

Fritz, this *is* known and is on purpose.
However, it seems that it is  NOT in the R-FAQ  (Kurt ?!?)

-- Martin

--------------- Here are two example mails from R-devel ------------------

 From: Peter Dalgaard BSA <p.dalgaard@kubism.ku.dk>
 Date: 25 Apr 1997 01:36:23 +0200
 To: r-devel@stat.math.ethz.ch
 Subject: R-alpha: list assignment

 This works in Splus:

 > x<-list()
 > x[["f"]]<-1
 > zz<-"g"
 > x[[zz]]<-2
 > x
 [1] 1

 [1] 2

 In R both variants fail unless the name is already on the list. The
 first one can be replaced by x$f, but there's seems to be no
 substitute for the other one (oh yes I found one, but it's not fit to
 print!). This comes up if you e.g. want to create a variable in a data
 frame with a name given by a character string.


 From: Robert Gentleman <rgentlem@stat.auckland.ac.nz>
 Date: Fri, 25 Apr 1997 13:12:36 +1200 (NZST)
 To: r-devel@stat.math.ethz.ch
 Subject: Re: R-alpha: list assignment

   They don't work on purpose. Basically this is the same problem as indexing
 beyond the end of an array. In almost all cases it is an error.
 To add a variable with a specific name to a data frame how about

 x (the dataframe)
 var1 the variable
 name1 the name


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