Re: [Rd] <<- (PR#7313)

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Tue 26 Oct 2004 - 01:43:03 EST

On Mon, 25 Oct 2004 bvaillant@simon-kucher.com wrote:

> Full_Name: Boris Vaillant
> Version: 2.0
> OS: Win 2000
> Submission from: (NULL) (195.227.11.98)
>
>
> ##Maybe I have not fully understood the changements
> ##in R 2.0.
> ## Why is it that
>
> a <- 1:3
> names(a) <- 1:3
> # works fine, but
>
> b <<- 1:3
> names(b) <<- 1:3
>
> ## used to work in R 1.9
> ## and gives
>> Error: Object "b" not found
> ## in R 2.0 ?
>

It was a bug in R 1.9.1 that this worked when typed at the top level. <<- is for use inside functions, eg:
> f<-function(x){

    b <<- x
    names(b) <<- x
  }
> f(1:3)
> b

1 2 3
1 2 3

         -thomas



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Oct 26 02:33:01 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:25 EST