[Rd] Package inclusion in R core implementation

2019-03-01 Thread Morgan Morgan
Hi, It sometimes happens that some packages get included to R like for example the parallel package. I was wondering if there is a process to decide whether or not to include a package in the core implementation of R? For example, why not include the Rcpp package, which became for a lot of user

[Rd] R C API resize matrix

2019-06-17 Thread Morgan Morgan
Hi, Is there a way to resize a matrix defined as follows: SEXP a = PROTECT(allocMatrix(INTSXP, 10, 2)); int *pa = INTEGER(a) To row = 5 and col = 1 or do I have to allocate a second matrix "b" with pointer *pb and do a "for" loop to transfer the value of a to b? Thank you Best regards Morgan

[Rd] Convert STRSXP or INTSXP to factor

2019-07-15 Thread Morgan Morgan
Hi, Using the R C PAI, is there a way to convert to convert STRSXP or INTSXP to factor. The idea would be to do in C something similar to the "factor" function (example below): > letters[1:5] # [1] "a" "b" "c" "d" "e" > factor(letters[1:5]) # [1] a b c d e # Levels: a b c d e There is the func

[Rd] Evaluate part of an expression at C level

2019-09-27 Thread Morgan Morgan
Hi, I am wondering if the below is possible? Let's assume I have the following expression: 1:10 < 5 Is there a way at the R C API level to only evaluate the 5th element (i.e 5 < 5) instead of evaluating the whole expression and then select the 5th element in the logical vector? Thank you Best r

[Rd] New matrix function

2019-10-11 Thread Morgan Morgan
Hi All, I was looking for a function to find a small matrix inside a larger matrix in R similar to the one described in the following link: https://www.mathworks.com/matlabcentral/answers/194708-index-a-small-matrix-in-a-larger-matrix I couldn't find anything. The above function can be seen as

Re: [Rd] New matrix function

2019-10-11 Thread Morgan Morgan
On Fri, 11 Oct 2019 10:45 Duncan Murdoch, wrote: > On 11/10/2019 6:44 a.m., Morgan Morgan wrote: > > Hi All, > > > > I was looking for a function to find a small matrix inside a larger > matrix > > in R similar to the one described in the following link: >

Re: [Rd] New matrix function

2019-10-11 Thread Morgan Morgan
no strict > criteria for base R inclusion, one criterion relevant in this case is that > the usefulness of a feature be proven in the package space first. > > Michael > > > On Fri, Oct 11, 2019 at 5:19 AM Morgan Morgan > wrote: > >> On Fri, 11 Oct 2019 10:45 Duncan

Re: [Rd] New matrix function

2019-10-11 Thread Morgan Morgan
; > On Fri, Oct 11, 2019 at 3:55 PM Morgan Morgan > wrote: > >> How do you prove usefulness of a feature? >> Do you have an example of a feature that has been added after proving to >> be >> useful in the package space first? >> >> Thank you, >> Morg

Re: [Rd] New matrix function

2019-10-11 Thread Morgan Morgan
sult. > > Avi > > [1] https://stat.ethz.ch/pipermail/r-devel/2012-June/064351.html > > On Fri, Oct 11, 2019 at 9:55 AM Morgan Morgan > wrote: > >> How do you prove usefulness of a feature? >> Do you have an example of a feature that has been added after proving

Re: [Rd] New matrix function

2019-10-11 Thread Morgan Morgan
gt; > > > Has someone looked into the image processing area for this? That sounds > > a little bit too high-level for base R to me (and I would be surprised > > if any mainstream programming language had this kind of functionality > > built-in). > > > > H.

[Rd] Questions on the R C API

2019-11-04 Thread Morgan Morgan
Hi All, I have some questions regarding the R C API. Let's assume I have a function which is defined as follows: R file: myfunc <- function(a, b, ...) .External(Cfun, a, b, ...) C file: SEXP Cfun(SEXP args) { args = CDR(args); SEXP a = CAR(args); args = CDR(args); SEXP b = CAR(args); ar

Re: [Rd] Questions on the R C API

2019-11-04 Thread Morgan Morgan
(...)" and use .Call instead of .External? Also does it mean that to avoid expression to be evaluated at the R level, I have to use "list" or "substitute"? The function "switch" in R does not use them but manage to achieve that. switch(1, "a", stop(&quo

[Rd] Aggregate function FR

2019-11-20 Thread Morgan Morgan
Hi, I was wondering if it would be possible to add an argument to the aggreagte function to retain NA by categories?(default can not to in order to avoid breaking code) Please see below example: df = iris df$Species[5] = NA aggregate(`Petal.Width` ~ Species, df, sum) # does not include NA aggrega

[Rd] Long vector support in data.frame

2020-01-23 Thread Morgan Morgan
Hi All, Happy New Year! I was wondering if there is a plan at some point to support long vectors in data.frames? I understand that it would need some internal changes to lift the current limit. If there is a plan what is currently preventing it from happening? Is it time, resources? If so is ther

[Rd] Hash functions at C level

2020-05-03 Thread Morgan Morgan
Dear R-dev, Hope you are all well. I would like to know if there is a hash function available for the R C API? I noticed that there are hash structures and functions defined in the file "unique.c". These would definitly suit my needs, however is there a way to access them at C level? Thank you for

[Rd] psum/pprod

2020-05-16 Thread Morgan Morgan
Good morning All, Just wanted to do quick follow-up on this thread: https://r.789695.n4.nabble.com/There-is-pmin-and-pmax-each-taking-na-rm-how-about-psum-td4647841.html For those (including the R-core team) of you who are interested in a C implementation of psum and pprod there is one in the "ki

[Rd] Precision of function mean,bug?

2020-05-20 Thread Morgan Morgan
Hello R-dev, Yesterday, while I was testing the newly implemented function pmean in package kit, I noticed a mismatch in the output of the below R expressions. set.seed(123) n=1e3L idx=5 x=rnorm(n) y=rnorm(n) z=rnorm(n) a=(x[idx]+y[idx]+z[idx])/3 b=mean(c(x[idx],y[idx],z[idx])) a==b # [1] FALSE

Re: [Rd] Precision of function mean,bug?

2020-05-21 Thread Morgan Morgan
e::mean() does a two-pass scan over the elements too lower the impact of > addition of values with widely different values (classical problem in > numerical analysis). But I can see how it may look like that. > > Cheers, > > Henrik > > > On Thu, May 21, 2020, 03:21 Morgan Mor

[Rd] subset data.frame at C level

2020-06-17 Thread Morgan Morgan
Hi, Hope you are well. I was wondering if there is a function at C level that is equivalent to mtcars$carb or .subset2(mtcars, "carb"). If I have the index of the column then the answer would be VECTOR_ELT(df, asInteger(idx)) but I was wondering if there is a way to do it directly from the name

Re: [Rd] subset data.frame at C level

2020-06-24 Thread Morgan Morgan
d27608/src/main/subscript.c#L226-L235 > > On Wed, Jun 17, 2020 at 6:11 AM Morgan Morgan > wrote: > >> Hi, >> >> Hope you are well. >> >> I was wondering if there is a function at C level that is equivalent to >> mtcars$carb or .subset2(mtcars

[Rd] Build a R call at C level

2020-06-30 Thread Morgan Morgan
Hi All, I was reading the R extension manual section 5.11 ( Evaluating R expression from C) and I tried to build a simple call to the sum function. Please see below. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x));

Re: [Rd] Build a R call at C level

2020-06-30 Thread Morgan Morgan
XP e = PROTECT(lang2(install(\"sum\"), x)); > > SEXP r_true = PROTECT(CONS(ScalarLogical(1), R_NilValue)); > > SETCDR(CDR(e), r_true); > > SET_TAG(CDDR(e), install(\"na.rm\")); > > Rf_PrintValue(e); > > SEXP ans = PROTECT(eval(e, R_GlobalEnv)); > > UNPRO

Re: [Rd] Build a R call at C level

2020-06-30 Thread Morgan Morgan
Sorry Dirk, I don't remember discussing this topic or alternatives with you at all. Have a nice day. On Tue, 30 Jun 2020, 14:42 Morgan Morgan, wrote: > Thanks Jan and Tomas for the feedback. > Answer from Jan is what I am looking for. > Maybe I am not looking in the right place

[Rd] Faster sorting algorithm...

2021-03-15 Thread Morgan Morgan
Hi, I am not sure if this is the right mailing list, so apologies in advance if it is not. I found the following link/presentation: https://www.r-project.org/dsc/2016/slides/ParallelSort.pdf The implementation of fsort is interesting but incomplete (not sure why?) and can be improved or made fast

Re: [Rd] Faster sorting algorithm...

2021-03-15 Thread Morgan Morgan
ilable? > > Avi > > On Mon, Mar 15, 2021 at 12:26 PM Morgan Morgan > wrote: > >> Hi, >> I am not sure if this is the right mailing list, so apologies in advance >> if >> it is not. >> >> I found the following link/presentation: >> ht

Re: [Rd] Faster sorting algorithm...

2021-03-17 Thread Morgan Morgan
Thank you Neal. This is interesting. I will have a look at pqR. Indeed radix only does C collation, I believe that is why it is not the default choice for character ordering and sorting. Not sure but I believe it can help address the following bugzilla item: https://bugs.r-project.org/bugzilla/show

Re: [Rd] Faster sorting algorithm...

2021-03-21 Thread Morgan Morgan
My apologies to Professor Neal. Thank you for correcting me. Best regards Morgan On Mon, 22 Mar 2021, 05:05 , wrote: > I think it is "Professor Neal" :) > > I also appreciate the pqR comparisons. > > On Wed, Mar 17, 2021 at 09:23:15AM +, Morgan Morgan wrote: &

[Rd] R Console Bug?

2021-04-16 Thread Morgan Morgan
Hi, I am getting a really weird behaviour with the R console. Here is the code to reproduce it. 1/ C code: --- SEXP printtest(SEXP x) { const int PBWIDTH = 30, loop = INTEGER(x)[0]; int val, lpad; double perc; char PBSTR[PBWIDTH], PBOUT[PBW

Re: [Rd] R Console Bug?

2021-04-17 Thread Morgan Morgan
shConsole is > a no-op for terminal console and your code just prints on stderr anyway > (which is not buffered). All this does is just a lot of \r output (which is > highly inefficient anywhere but in Terminal by definition). Can you clarify > what the code tries to trigger? > > Ch

Re: [Rd] How to get utf8 string using R externals

2021-06-02 Thread Morgan Morgan
On Wed, 2 Jun 2021, 22:31 Duncan Murdoch, wrote: > On 02/06/2021 4:33 p.m., xiaoyan yu wrote: > > I have a R Script Predict.R: > > set.seed(42) > > C <- seq(1:1000) > > A <- rep(seq(1:200),5) > > E <- (seq(1:1000) * (0.8 + (0.4*runif(50, 0, 1 > > L <- ifelse(runif(100