Re: [Rd] SUGGESTION: Settings to disable forked processing in R, e.g. parallel::mclapply()

2020-01-09 Thread Henrik Bengtsson
I'd like to pick up this thread started on 2019-04-11 (https://hypatia.math.ethz.ch/pipermail/r-devel/2019-April/077632.html). Modulo all the other suggestions in this thread, would my proposal of being able to disable forked processing via an option or an environment variable make sense? I've pro

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Pages, Herve
On 1/9/20 06:56, Stepan wrote: > On 09. 01. 20 15:41, lille stor wrote: > >> I believe this could be done without creating side effects (e.g. >> crash) as we are just talking about changing values. A crash would certainly be an annoying "side effect" ;-) As Stepan explained, data.frame objects

Re: [Rd] mean

2020-01-09 Thread Stephen Ellison
Note that in > > quantile(c("1","2","3"),p=.5) > Error in (1 - h) * qs[i] : > argument non numérique pour un opérateur binaire the default quantile type (7) does not work for non-numerics. Quantile types 1 and 3 work as expected: > quantile(c("1","2","3"),p=.5, type=1) 50% "2" > quantile(c(

Re: [Rd] mean

2020-01-09 Thread Marc Schwartz via R-devel
Peter, Thanks for the reply. If that were the case, then should not the following be allowed to work with ordered factors? > median(factor(c("1", "2", "3"), ordered = TRUE)) Error in median.default(factor(c("1", "2", "3"), ordered = TRUE)) : need numeric data At least on the surface, if you

Re: [Rd] mean

2020-01-09 Thread peter dalgaard
I think median() behaves as designed: As long as the argument can be ordered, the "middle observation" makes sense, except when the middle falls between two categories, and you can't define and average of the two candidates for a median. The "sick man" would seem to be var(). Notice that it is a

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Stepan
On 09. 01. 20 15:41, lille stor wrote: I believe this could be done without creating side effects (e.g. crash) as we are just talking about changing values. that is exactly the issue that my last two points warn about. Example: a <- mtcars .Call("my_innocent_function", a) Would you expect th

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Tomas Kalibera
On 1/9/20 1:03 PM, Ezra Tucker wrote: Hi Lille, Is it possible you're looking for tracemem() or inspect() ? Please note these functions are only for debugging. They should never be called from programs or packages. One should never try to manipulate pointers from R directly or even hold them

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Stepan
Hello Lille, raw data of a data.frame (or more precisely a list, because data.frame is just a list with "data.frame" class) is an array of R specific data structures (SEXP), so a generic C function will not be able to work with them. As a per-processing step, you may allocate an array for th

Re: [Rd] mean

2020-01-09 Thread Marc Schwartz via R-devel
Jean-Luc, Please keep the communications on the list, for the benefit of others, now and in the future, via the list archive. I am adding r-devel back here. I can't speak to the rationale in some of these cases. As I noted, it may be (is likely) due to differing authors over time, and there may

Re: [Rd] mean

2020-01-09 Thread Marc Schwartz via R-devel
> On Jan 9, 2020, at 7:40 AM, Lipatz Jean-Luc wrote: > > Hello, > > Is there a reason for the following behaviour? >> mean(c("1","2","3")) > [1] NA > Warning message: > In mean.default(c("1", "2", "3")) : > l'argument n'est ni numérique, ni logique : renvoi de NA > > But: >> var(c("1","2","3

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Joris Meys
Hi Lille, To my understanding, there's no need to get the actual memory address of the R data frame, as using .Call() or .External() can be used in a "call by reference" way as well. This would be contrary to standard R behaviour, so if you use that in a package, make sure you indicate this! Ther

[Rd] mean

2020-01-09 Thread Lipatz Jean-Luc
Hello, Is there a reason for the following behaviour? > mean(c("1","2","3")) [1] NA Warning message: In mean.default(c("1", "2", "3")) : l'argument n'est ni numérique, ni logique : renvoi de NA But: > var(c("1","2","3")) [1] 1 And also: > median(c("1","2","3")) [1] "2" But: > quantile(c("1","

Re: [Rd] Get memory address of an R data frame

2020-01-09 Thread Ezra Tucker
Hi Lille, Is it possible you're looking for tracemem() or inspect() ? > x <- data.frame(z = 1:10)> tracemem(x)[1] "<0x55aa743e0bc0>" > x[1] <- 2Ltracemem[0x55aa743e0bc0 -> 0x55aa778f6ad0]: tracemem[0x55aa778f6ad0 -> 0x55aa778f6868]: [<-.data.frame [<- tracemem[0x55aa778f6868 -> 0x55aa778f5b48]:

[Rd] Get memory address of an R data frame

2020-01-09 Thread lille stor
Hello, I would like for my C function to be able to manipulate some values stored in an R data frame. To achieve this, a need the (real) memory address where the R data frame stores its data (hopefully in a contiguous way). Then, from R, I call the C function and passing this memory address as