similar to: PROTECT help

Displaying 20 results from an estimated 700 matches similar to: "PROTECT help"

2003 Nov 03
2
lang2(...) with two and more arguments
Dear R-help, how could I create an R call in C code using lang2 with 2 and more arguments? I tried this code: SEXP f(SEXP fn, SEXP rho) { SEXP R_fcall, x, y; PROTECT(R_fcall = lang2(fn, R_NilValue)); PROTECT(x = allocVector(REALSXP, 1)); PROTECT(y = allocVector(REALSXP, 1)); REAL(x)[0] = 10; REAL(y)[0] = 20; SETCADR(R_fcall, x); SETCADR(R_fcall, y);
2009 Sep 16
2
I want to get a reference to this time series object
I'm trying to get a reference to this object in C SWX.RET[1:6,c("SBI,"SPI","SII")] While i am able to access and use a plain SWX.RET object, I'm getting confused on how to create an object with the array subscripts like above. Here is what I tried to do. It doesn't work because "[" is obviously not an operation or function on SWX.RET. So how do I
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 <-
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
2009 Sep 29
3
How do I access class slots from C?
Hi I'm trying to implement something similar to the following R snippet using C. I seem to have hit the wall on accessing class slots using C. library(fPortfolio) lppData <- 100 * LPP2005.RET[, 1:6] ewSpec <- portfolioSpec() nAssets <- ncol(lppData) setWeights(ewSpec) <- rep(1/nAssets, times = nAssets) ewPortfolio <- feasiblePortfolio( data = lppData, spec = ewSpec,
2019 May 01
3
anyNA() performance on vectors of POSIXct
Inside of the anyNA() function, it will use the legacy any(is.na()) code if x is an OBJECT(). If x is a vector of POSIXct, it will be an OBJECT(), but it is also TYPEOF(x) == REALSXP. Therefore, it will skip the faster ITERATE_BY_REGION, which is typically 5x faster in my testing. Is the OBJECT() condition really necessary, or could it be moved after the switch() for the individual TYPEOF(x)
2020 Jun 30
2
Build a R call at C level
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)); SEXP ans = PROTECT(eval(e, R_GlobalEnv)); UNPROTECT(2); return
2006 Oct 22
1
Getting hold of a package's environment from C code
Hi, I have a package where I'm calling an R function (say "foo") from C code. "foo" is in the same package, but is not exported. I construct the call using lang1(install("foo")), but to eval it I need the package's environment. Is there a way to do this? Passing the correct environment through .Call() is not an option. Right now, I'm getting the
2009 Oct 29
2
Help with lang4
Hi I seem to have run into a situation where I have more than 3 arguments to pass to a function from C. the following functions help me build an expression for evaluation: lang lang2 lang3 lang4 What should one do if there are more arguments than lang4 can handle? Regards Abhijit Bera [[alternative HTML version deleted]]
2003 Jan 16
1
Calling R function from within C code
Dear R experts, I'd like to call R function from within C code. I looked through the 'R exts' manual, found examples with lang2(R_fcall, list), and tried it, but it seemed to create the call, which can accept only a single argument of 'list' type, when I need to create the call of R functions with arbitrary numbers of arguments. How can I do it? Thanks a lot. -- WBR,
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
2011 Apr 25
3
Interrupting C++ code execution
Hello, I am writing an R interface for one of my C++ programs. The computations in C++ are very time consuming (several hours), so the user needs to be able to interrupt them. Currently, the only way I found to do so is calling R_CheckUserInterrupt() frequently. Unfortunately, there are several problems with that: 1. Calling R_CheckUserInterrupt() interrupts immediately, so I have no
2011 Mar 04
2
Fixing the HDF5 package: the on.exit mystery
Dear all, I'm trying to fix a subtle bug in the hdf5 package. This package provides an interfaces to the HDF5 library and hence allows one to load data into R from files in the HDF5 format. The bug appeared during a period in which R changed but the package did not. I include below both the R and C code, stripped of everything except what is needed to show the bug. What is supposed to
2020 Mar 23
5
help with rchk warnings on Rf_eval(Rf_lang2(...))
Thanks, that's really useful. One more question for you, or someone else here: const ArrayXd glmLink::linkFun(const ArrayXd& mu) const { return as<ArrayXd>(::Rf_eval(::Rf_lang2(as<SEXP>(d_linkFun), as<SEXP>(Rcpp::NumericVector(mu.data(), mu.data() + mu.size())) ), d_rho); } I guess I need that to read
2015 Jan 20
1
[PATCH] Makefile: add support for git svn clones
Fellipe, CXXR development has moved to github, and we haven't fixed up the build for using git yet. Could you send a pull request with your change to the repo at https://github.com/cxxr-devel/cxxr/? Also, this patch may be useful for pqR too. https://github.com/radfordneal/pqR Thanks On Mon, Jan 19, 2015 at 2:35 PM, Dirk Eddelbuettel <edd at debian.org> wrote: > > On 19
2011 Jan 26
2
Dealing with R list objects in C/C++
Hi, I'd like to construct an R list object in C++, fill it with relevant data, and pass it to an R function which will return a different list object back. I have browsed through all the R manuals, and examples under tests/Embedding, but can't figure out the correct way. Below is my code snippet: #include <Rinternals.h> // Rf_initEmbeddedR and other setups already performed
2014 Mar 06
1
Create dataframe in C from table and return to R
Hi , I am trying to create a dataframe in C and sebd it back to R. Can anyone point me to the part of the source code where it is doing , let me explain the problem I am having . -------------------------------------------------------------------- My simple implementation is like this SEXP formDF() { SEXP dfm ,df , dfint , dfStr,lsnm; char *ab[3] =
2003 Oct 31
1
Optimization of objective function with generic number of arguments (R-Extension with C code)
Hi All! I'm a new subscriber to this mailing list. I'm writing an R extension with C linked code having a minimization function letting me pass it an objective function with a GENERIC number of arguments and letting me to optimize over a specific one among them if there are many. ################################################# ############### IPOTETICAL MAIN ###############
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
2015 Jan 19
3
[PATCH] Makefile: add support for git svn clones
On 19/01/2015 4:13 PM, Nathan Kurz wrote: > On Mon, Jan 19, 2015 at 1:00 PM, Felipe Balbi <balbi at kernel.org> wrote: >> I just thought that such a small patch which causes no visible change to >> SVN users and allow for git users to build R would be acceptable, but if >> it isn't, that's fine too. > > Felipe --- > > It would appear that you are