Re: [Rd] Assignment in environment

2016-02-07 Thread Daniel Kaschek
On So, Feb 7, 2016 at 2:46 , Duncan Murdoch wrote: An assignment function should return the modified value. So it looks like you would need 'getValue<-' <- function(x, value) { environment(x)$mylist <- value x } Thanks. I have not thought of a return value. That makes the differen

[Rd] Assignment in environment

2016-02-07 Thread Daniel Kaschek
Dear all, I have a function "fn" with its own environment, i.e. env <- environment(fn) and env is not .GlobalEnv. And another function getValue <- function(x) environment(x)$mylist which returns the list object "mylist" which is in "env". If I want to modify "mylist", I could write 'getVal

Re: [Rd] Multiple cores are used in simple for loop

2016-01-15 Thread Daniel Kaschek
Dear Martyn, On Fr, Jan 15, 2016 at 4:01 , Martyn Plummer wrote: Alternatively, you may be able to control the maximum number of threads by setting and exporting an appropriate environment variable depending on what backend you are using, e.g. OPENBLAS_NUM_THREADS or MKL_NUM_THREADS. Tha

[Rd] Multiple cores are used in simple for loop

2016-01-15 Thread Daniel Kaschek
Dear all, I run different R versions (3.2.1, 3.2.2 and 3.2.3) on different platforms (Arch, Ubuntu, Debian) with a different number of available cores (24, 4, 24). The following line produces very different behavior on the three machines: for(i in 1:1e6) {n <- 100; M <- matrix(rnorm(n^2), n,

Re: [Rd] iterated lapply

2015-02-24 Thread Daniel Kaschek
> return(myfn) > > }) > > > > sapply(test, function(myfn) myfn(2)) > > > > > > > > Cheers, > > Daniel > > > -- Daniel Kaschek Institute of Physics Freiburg University Room 210 Phone: +49 761 2038531 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] iterated lapply

2015-02-23 Thread Daniel Kaschek
this a bug or a feature? conditions <- 1:4 test <- lapply(conditions, function(mycondition){ #print(mycondition) myfn <- function(i) mycondition*i return(myfn) }) sapply(test, function(myfn) myfn(2)) Cheers, Daniel -- Daniel Kaschek Institute of Physics Freiburg University Room