Thanks! I'll try to stick to that advice! Maybe there is a better way... Here is what I want:
I want to save some default settings for a package. The user can change these using a function similar to par(). I do not want to use options() here as it will be quite a lot of parameters. I was thinking about an invisible object in the global environment and using <<- or assign() to change the settings... What other roads are there to go? TIA --Mark Am 07.04.2012 um 22:51 schrieb Henrik Bengtsson: > On Sat, Apr 7, 2012 at 1:30 PM, Mark Heckmann <mark.heckm...@gmx.de> wrote: >> Hello, >> >> using the <<- assignment operator I do not understand why the following does >> not work. >> >> l <<- list() >> l >> list() >> l$arg1 <<- "test" >> error in l$arg1 <<- "test" : Objekt 'l' not found >> >> ?"<<-" says: "The operators <<- and ->> cause a search to made through the >> environment for an existing definition of the variable being assigned. If >> such a variable is found (and its binding is not locked) then its value is >> redefined, otherwise assignment takes place in the global environment. " >> >> Still I do noch understand why the above does not work. The object l is in >> the global environment. Can someone explain it to me? > > Yes, the object 'l' is in the global environment, but 'l$arg1' is not, > cf. exists("l$arg1") and exists("l"). Instead, this works: > > l <<- list(); > l$args1 <- "test"; > > but much much much much much much much much much much much much much > much much much much much much much much much much much much much much > much much much much much much much much much much much better, do NOT > use "<<-" (or assign()/get()) unless you fully understand what you're > doing and have a very good reason for doing it, and that reason should > be able pass the embarrassment-test on public R mailing lists. Got > the point? Don't use it - there is another way to do what you want to > achieve - you just have to ask/find out how. > > /H > >> >> Thanks >> --Mark >> >> Mark Heckmann >> Blog: www.markheckmann.de >> R-Blog: http://ryouready.wordpress.com >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. Mark Heckmann Blog: www.markheckmann.de R-Blog: http://ryouready.wordpress.com [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.