similar to: How to grow an R object from C (.Call Interface)

Displaying 20 results from an estimated 1000 matches similar to: "How to grow an R object from C (.Call Interface)"

2003 Dec 12
3
C++: Appending Values onto an R-Vector.
Hi folks. I posted this question a few days ago, but maybe it got lost because of the code I included with it. I'm having a problem using the SET_LENGTH() macro in an R extension I'm writing in C++. In a function within the extension I use SET_LENGTH() to resize R vectors so as to allow the concatenation of single values onto the vectors -- it's a "push back" function to
2017 Jun 05
2
Usage of PROTECT_WITH_INDEX in R-exts
Hi I've noted a minor inconsistency in the documentation: Current R-exts reads s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), &ipx); but I believe it has to be PROTECT_WITH_INDEX(s = eval(OS->R_fcall, OS->R_env), &ipx); because PROTECT_WITH_INDEX() returns void. Best regards Kirill
2017 Jun 06
2
Usage of PROTECT_WITH_INDEX in R-exts
On 06.06.2017 10:07, Martin Maechler wrote: >>>>>> Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> >>>>>> on Mon, 5 Jun 2017 17:30:20 +0200 writes: > > Hi I've noted a minor inconsistency in the documentation: > > Current R-exts reads > > > s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), &ipx);
2017 Jun 09
1
Usage of PROTECT_WITH_INDEX in R-exts
>>>>> Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> >>>>> on Thu, 8 Jun 2017 12:55:26 +0200 writes: > On 06.06.2017 22:14, Kirill M?ller wrote: >> >> >> On 06.06.2017 10:07, Martin Maechler wrote: >>>>>>>> Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> on
2013 Nov 05
1
Dynamic list creation (SEXP in C) returns error "unimplemented type (29) in 'duplicate'"
Dear R-devel, A couple of weeks ago I started to use the R C API for package development. Without knowing much about C, I've been able to write some routines sucessfully... until now. My problem consists in dynamically creating a list ("L1") of lists using .Call, the tricky part is that each element of the "mother list" contains two vectors (INTSXP and REALEXP types) with
2010 Aug 23
1
Speed improvement to PROTECT, UNPROTECT, etc.
As I mentioned in my previous message about speeding up evalList, I've been looking at ways to speed up the R interpreter. One sees in the code many, many calls of PROTECT, UNPROTECT, and related functions, so that seems like an obvious target for optimization. Indeed, I've found that one can speed up the interpreter by about 10% by just changing these. The functions are actually macros
2010 Jan 02
3
R-devel Digest, Vol 83, Issue 2
[Disclaimer: what is below reflects my understanding from reading the R source, others will correct where deemed necessary] On 1/2/10 12:00 PM, r-devel-request at r-project.org wrote: > > Hello, > > We are currently making lots of changes to Rcpp (see the open Rcpp > mailing list if interested [1] in the details). > > We are now using [2] R_PreserveObject and R_ReleaseObject
2009 Jan 08
1
Callbacks seems to get GCed.
Dear list, I am trying to implement a publish-subscribe mechanism in for an embedded R interpreter. But somehow my registered closures seem to get collected by the GC, even though I have protected them. I have reducted my code to the following sample. Sorry if it is a little verbose. The first couple of call of calls still work, but at some point one of the callbacks (callback1 in my
2005 Apr 16
1
SET_LENGTH
Hello. I'm trying to read a delimited file. I'm a little new to the R api. In the program, I do something like this... /*****************************/ SEXP retval; PROTECT(retval = allocMatrix(STRSXP,1,names.dim)); int r_eltctr = 0; while(!myfile.eof()) { SET_LENGTH(retval,r_eltctr+num_of_fields); for(int i = 0;numofcolumns; ++i) { INTEGER(retval)[r_eltctr++] = 1;/*some
2004 Aug 12
4
truly object oriented programming in R
Good morning! I recently implemented a KD tree in JAVA for faster kernel density estimation (part of the code follows). It went well. To hook it with R, however, has proved more difficult. My question is: is it possible to implement the algorithm in R? My impression seems to indicate no as the code requires a complete class-object framework that R does not support. But is there an R package or
2017 Jun 06
0
Usage of PROTECT_WITH_INDEX in R-exts
>>>>> Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> >>>>> on Mon, 5 Jun 2017 17:30:20 +0200 writes: > Hi I've noted a minor inconsistency in the documentation: > Current R-exts reads > s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), &ipx); > but I believe it has to be > PROTECT_WITH_INDEX(s =
2017 Jun 08
0
Usage of PROTECT_WITH_INDEX in R-exts
On 06.06.2017 22:14, Kirill M?ller wrote: > > > On 06.06.2017 10:07, Martin Maechler wrote: >>>>>>> Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> >>>>>>> on Mon, 5 Jun 2017 17:30:20 +0200 writes: >> > Hi I've noted a minor inconsistency in the documentation: >> > Current R-exts reads >>
2003 Nov 18
1
How to return a big treelike list from .Call Interface (protect stack overflow)
I try to create a big treelike list structure using the RDefines/RInternal macros. The tree carries information at each node (attribute list) and at each leaf (vector). My understanding is that for each node I add to the binary tree I have to call PROTECT(newnode = NEW_LIST(2)); and cannot UNPROTECT before I return the whole tree. Same story for node attributes and leaf vectors. However, this
2009 Sep 22
2
cannot build R-devel (>= r49747)
Hello, I've tried several times yesterday to build R-devel and I consistently get this error when I "make" : mkdir -p -- ../../../library/base/R make[3]: Leaving directory `/tmp/R-devel/src/library/profile' make[3]: Entering directory `/tmp/R-devel/src/library/base' building package 'base' make[4]: Entering directory `/tmp/R-devel/src/library/base' mkdir -p --
2002 Jun 12
1
identical calls are not equal !?
Can please someone familiar with the R internals enlighten me on the following strange observation: # this is IDENTICAL as expected identical(substitute(substitute()), substitute(substitute())) # but NOT EQUAL !???? substitute(substitute()) == substitute(substitute()) # I originally found it on t2 <- function(e){ substitute(e) } t2(substitute(x==y, list(y=y)))[1] # I would expect all
2008 Aug 04
2
Parsing code with newlines
Dear List, When I try to parse code containing newline characters with R_ParseVector, I get a compilation error. How can I compile code that includes comments and newlines? I am using the following: void* my_compile(char *code) { SEXP cmdSexp, cmdExpr = R_NilValue; ParseStatus status; PROTECT (cmdSexp = allocVector (STRSXP, 1)); SET_STRING_ELT (cmdSexp, 0, mkChar (code));
2020 Jun 26
2
Error in substring: invalid multibyte string
Hi all, I'm getting the following error from substring: > substr("<I>Jens Oehlschl\xe4gel-Akiyoshi", 1, 100) Error in substr("<I>Jens Oehlschl\xe4gel-Akiyoshi", 1, 100) : invalid multibyte string at '<e4>gel-A<6b>iyoshi' Is that normal / intended? I've tried setting the Encoding/locale to Latin-1/UTF-8 but that does not help. nchar
2020 Jun 27
1
Error in substring: invalid multibyte string
Thanks for the quick response Ivan. readLines with encoding='latin1' works for me (on Ubuntu). However I was more concerned with the inconsistency in results between substr and regexpr. I was expecting that if one of them errors because of an unknown encoding then the other should as well. Even better, if regexpr works, why shouldn't substr work as well? Incidentally the analogous
2006 Aug 07
2
Backquote in R syntax
Hi Folks, Can someone satisfy my curiosity (well, at least about the following query!) Reading the draft proofs of an article I've been asked to look through, I find the typesetter has set what would normally be entered as source("xyz.R") or source('xyz.R') as source(`xyz.R') i.e. it has come out with an opening backquote, then xyz.R, then a closing forward
2009 Nov 28
1
PROTECT and OCaml GC.
Hello. In the writing of my OCaml-R binding, I'm sort of confused when it comes to the use of the PROTECT and UNPROTECT macros. Basically, I have C stub functions that are in charge of calling R for everything. Here's a simple example: > CAMLprim value r_findvar (value symbol) { > /* The findVar function is defined in envir.c. It looks up a symbol > in an environment.