similar to: Build a R call at C level

Displaying 20 results from an estimated 600 matches similar to: "Build a R call at C level"

2020 Jun 30
3
Build a R call at C level
On 6/30/20 1:06 PM, Jan Gorecki wrote: > It is quite known that R documentation on R C api could be improved... Please see "5.11 Evaluating R expressions from C" from "Writing R Extensions" Best Tomas > Still R-package-devel mailing list should be preferred for this kind > of questions. > Not sure if that is the best way, but works. > > call_to_sum <-
2020 Jun 30
0
Build a R call at C level
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 buy it is not easy to understand how these LCONS, CONS, SETCDR...etc works. Thank you Best regards Morgan On Tue, 30 Jun 2020, 12:36 Tomas Kalibera, <tomas.kalibera at gmail.com> wrote: > On 6/30/20 1:06 PM, Jan Gorecki wrote: > > It is quite known that R
2020 Jun 30
0
Build a R call at C level
It is quite known that R documentation on R C api could be improved... Still R-package-devel mailing list should be preferred for this kind of questions. Not sure if that is the best way, but works. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x)); SEXP r_true =
2014 Apr 03
1
question regarding lang2 command in C
Hi , I am asking too many questions , sorry for that . I am creating a data frame in C itself , reading a table . The data frame calling code looks like this ====================================== *PROTECT(dfm=lang2(install("data.frame"),df));* *SEXP res = PROTECT(eval(dfm,R_GlobalEnv));* UNPROTECT(2); return res; ================================== It works fine , now the problem
2009 Aug 25
2
Clarifications please.
Hi I think I have asked these questions earlier, but I been able to find answers from the documentation (which I found poorly written in several places). Will someone be kind enough to give me answers and enlighten me? (as in explain with CODE?) I want to embed R in my application and use the fPortfolio package for carrying out risk management computations. Right now I'm reading the Rmetrics
2020 Sep 11
4
Garbage collection of seemingly PROTECTed pairlist
I want to write an R function using R's C interface that takes a 2-column matrix of increasing, non-overlapping integer intervals and returns a list with those intervals plus some added intervals, such that there are no gaps. For example, it should take the matrix rbind(c(5L, 6L), c(7L, 10L), c(20L, 30L)) and return list(c(5L, 6L), c(7L, 10L), c(11L, 19L), c(20L, 30L)). Because the output is
2014 Jun 25
1
Need help on calling Head from C
Hi , I am trying to call head function from C . My doubt is with the parameter n,how to pass it . PROTECT(dfm=lang3(install("data.frame"),df,ScalarLogical(FALSE))); SET_TAG(CDDR(dfm), install("stringsAsFactors")) ; SEXP res = PROTECT(eval(dfm,R_GlobalEnv)); PROTECT(head=lang3(install("head"),res,ScalarInteger(1))); head = PROTECT(eval(head,R_GlobalEnv)); I tried
2014 Oct 31
3
ScalarLogical and setAttrib
Is it expected that attributes set on a LGLSXP created by ScalarLogical will apply to all future objects created by ScalarLogical as well? For example: the 'test1' function below returns FALSE and 'test2' returns FALSE with an attribute: library(inline) test1 <- cfunction(body = 'return ScalarLogical(0);') test2 <- cfunction(body = ' SEXP success =
2023 Apr 29
1
Forcing a PROTECT Bug to Occur
I'm trying to learn about R's PROTECT system. To that end I've tried to create an example of C code that doesn't protect anything. I was hoping it would either segfault from trying to access deallocated memory, or maybe print out nonsense results because the unprotected memory got overwritten, but I can't make either happen. Here's my current code (all in R, using the
2008 Apr 24
1
Calling R functions with multiple arguments from C
Hi, I'm writing a C function that has to call a R function with multiple arguments. I've read the relevant section in Writing R Extensions, and searched the R site, mailing lists as well as rseek. I managed to call the function, but I'm now having trouble creating the argument list. I tried to create a pairlist of the arguments and send it to the R function. The R function however
2010 Nov 22
4
How to call R from C
Hi all! I read R Extensions manual. But still I am not sure how to call R functions from C. Would any of you give me a sample C code to show how to call R functions - for instance, time series functions - from C in the embedded way of C code? [[alternative HTML version deleted]]
2019 Jan 05
1
unsorted - suggestion for performance improvement and ALTREP support for POSIXct
I believe the performance of isUnsorted() in sort.c could be improved by calling REAL() once (outside of the for loop), rather than calling it twice inside the loop. As an aside, it is implemented in the faster way in doSort() (sort.c line 401). The example below shows the performance improvement for a vectors of double of moving REAL() outside the for loop. # example as implemented in
2017 Mar 03
2
Control statements with condition with greater than one should give error (not just warning) [PATCH]
I'd like to propose that the whenever the length of condition passed to an if or a while statement differs from one, an error is produced rather than just a warning as today: > x <- 1:2 > if (x == 1) message("x == 1") x == 1 Warning message: In if (x == 1) message("x == 1") : the condition has length > 1 and only the first element will be used There are
2007 Apr 07
2
Rf_PrintValue problem with methods::show
Hi, I think this is a bug (even though I can't find documentation explicitly saying that it should work). Basically, Rf_PrintValue(obj) fails when 'obj' is an S4 object that should be printed using show() rather than print(). From the error message I'm guessing that the need to use show is detected correctly but then show is not found. "cbind2" in the code below is just
2019 Nov 04
2
Questions on the R C API
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); args = CDR(args); /* continue to do something with remaining arguments in "..."
2018 Mar 18
3
`@<-` modify its argument when slot is externalptr
Dear all, I am confused about the inconsistent behaviors of `@<-` operator when used in different ways. Consider the following example: library(inline) # Function to generate an externalptr object with random address new_extptr <- cfunction(c(), ' SEXP val = PROTECT(ScalarLogical(1)); SEXP out = PROTECT(R_MakeExternalPtr(&val, R_NilValue, val)); UNPROTECT(2);
2009 Jun 26
1
bug in Rf_PrintValue ?
I'm very green with R, so maybe this is not a bug, but it looks like one to me. The following program segfaults at the second call to Rf_PrintValue(). To failure depends on the value of the y-string. E.g., if I change it from "coverage" to, say, "COVERAGE", the segfault does not occur. /* bug.c */ #include <stdio.h> #include <Rinternals.h> #include
2010 Aug 21
1
Speed improvement to evalList
I've been inspired to look at the R source code by some strange timing results that I wrote about on my blog at radfordneal.wordpress.com (see the posts on "Speeding up parentheses..." and "Two surprising things...". I discovered that the strange speed advantage of curly brackets over parentheses is partially explained by an inefficiency in the evalList and
2008 Mar 29
0
"Writing R Extensions": bad example with CAR / CDR as lvalues (PR#11054)
Full_Name: Simon Anders Version: 2.6.2 OS: Ubuntu Linux Submission from: (NULL) (86.22.75.91) This is a rather minor "documentation bug", certainly not at all urgent. The manual "Writing R extensions" explains in section 5.10 ("Evaluating R expressions from C") how to use the eval function. Without going into much details, an example is given how to build up a
2012 Mar 27
2
PROTECT help
I received the following note this AM. The problem is, I'm not quite sure how to fix it. Can one use PROTECT(coxlist(eval(PROTECT.... , do I create an intermediate variable, or otherwise? I'm willing to update the code if someone will give me a pointer to the right documentation. This particular chunk was written when there was a lot of change going on in the callback mechanism and