Dear Helpers, in which way I have to use the assignment-operator evaluating left to right with R 2.0.0? With R 2.0.0 (w2k-installation) the "superassignment" operator '<<-' seems to have a different behaviour compared with R 1.9.1 : > x<<-4 > x [1] 4 > attr(x,'y')<<-5 Error: Object "x" not found > Using earlier versions of R I never got this error. In the NEWS file and the docs coming along with R 2.0.0 I did not found anything concerning this problem. AFAIK '=' instead of '<<-' works - but is allowed only for toplevel- assignments. Thanks in advance, Friedemann
On Fri, 8 Oct 2004, friedemann wrote:> Dear Helpers, > > in which way I have to use the assignment-operator evaluating left to right > with R 2.0.0?<- is the operator you should normally use.> With R 2.0.0 (w2k-installation) the "superassignment" operator '<<-' seems to > have a different behaviour compared with R 1.9.1 : > > > x<<-4 > > x > [1] 4 > > attr(x,'y')<<-5 > Error: Object "x" not found > > > > Using earlier versions of R I never got this error. > > In the NEWS file and the docs coming along with R 2.0.0 I did not found > anything concerning this problem.Did you not notice NEWS contains o Complex superassignments were wrong when a variable with the same name existed locally, and were not documented in R-lang.> AFAIK '=' instead of '<<-' works - but is allowed only for toplevel- > assignments.= is allowed almost everywhere <- is, and not just at top-level. I don't know what you are really trying to do, but x <- 4 testit <- function() attr(x,'y') <<- 5 testit() x works as documented, and that is the normal type of usage of superassignments. As the NEWS entry says, R-lang (`The R Language Definition') gives fuller details (and I guess the help page for <<- should point there). -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
"friedemann" <friedemann at gehrt.info> writes:> With R 2.0.0 (w2k-installation) the "superassignment" operator '<<-' seems to > have a different behaviour compared with R 1.9.1 : > > > x<<-4 > > x > [1] 4 > > attr(x,'y')<<-5 > Error: Object "x" not found > > > > Using earlier versions of R I never got this error. > > In the NEWS file and the docs coming along with R 2.0.0 I did not found > anything concerning this problem.It's there. Look for "complex superassignment".> AFAIK '=' instead of '<<-' works - but is allowed only for toplevel- > assignments.Eh? You mean "assignments in the current environment"? Why do you want to use <<- at top level (the command-line) anyway? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Maybe Matching Threads
- WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
- WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
- WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
- WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
- Return variable assignments from a function