[R] Simple syntax question (I think)

Bert Gunter bgunter.4567 at gmail.com
Wed Jan 20 19:26:03 CET 2016


Could someone please explain to me my mal-understanding of the
following, which I expected to give the same results without errors.

TIA.

-- Bert

> z <-  list(x=1)
> z[[2]] <- 3
> z
$x
[1] 1

[[2]]
[1] 3

> list(x = 1)[[2]] <- 3
Error in list(x = 1)[[2]] <- 3 :
  target of assignment expands to non-language object
>
> sessionInfo()

R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] utils    datasets tools    stats    graphics splines  grid
methods  base

other attached packages:
[1] nlme_3.1-122    lattice_0.20-33

loaded via a namespace (and not attached):
[1] grDevices_3.2.3 strucplot_0.5



Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )



More information about the R-help mailing list