[Rd] <<- (PR#7313)

Thomas Lumley tlumley at u.washington.edu
Mon Oct 25 17:43:03 CEST 2004


On Mon, 25 Oct 2004 bvaillant at 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



More information about the R-devel mailing list