Displaying 20 results from an estimated 4000 matches similar to: "dynamic lists at C level"
2014 May 16
1
SEXPTYPEs
Dear list,
On a follow up from my previous email, I am now trying to allocate vectors
of length larger than 32-bit in C.
>From the R internals documentation, I read that:
"The sxpinfo header is defined as a 32-bit C structure..."
and
"A SEXPREC is a C structure containing the 32-bit header..."
The question is: does the INTSXP allow vectors larger than 32-bit?
A test
2014 Jun 24
2
using C code to create data frame but always return as list
there is my code, expect return value is a data frame but R say it is list:
SEXP Julia_R_MD_NA_DataFrame(jl_value_t* Var)
{
SEXP ans,names,rownames;
char evalcmd[4096];
int i;
const char* dfname="DataFrameName0tmp";
jl_set_global(jl_main_module, jl_symbol(dfname), (jl_value_t*)Var);
//Get Frame cols
sprintf(evalcmd,"size(%s,2)",dfname);
jl_value_t*
2006 Nov 17
1
Manipulating R lists in C
Hi,
I have been studying the R manual on lists but cannot seem to create a
simple R list in C - I keep on getting "'dimnames' applied to non-array"
whenever I attempt to assign names to the list elements:
Wanted output a list structure something like
[ type="Bid", price=2.0, volume=1000 ]
I can get up to a list of
[ "Bid2, 2.0, 1000 ]
But for the life of
2003 Sep 05
1
Problem with S4 slots in C code (PR#4073)
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C3738F.63DE3390
Content-Type: text/plain;
charset="iso-8859-1"
#I want to be able to create a new S4 class and read data into it using C
code
# Here is a very simple S4 object inheriting from "array", but with 5
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] =
2011 Jan 17
1
isoreg memory leak?
I believe there is a memory leak in isoreg in the current version of R,
as I believe the following shows
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 120405 3.3 350000 9.4 350000 9.4
Vcells 78639 0.6 786432 6.0 392463 3.0
> for(k in 1:100) {
+
+ y <- runif(10000)
+ isoreg(x,y)
+ }
> rm(x)
> rm(y)
> gc()
used (Mb) gc
2006 Mar 27
1
Safe to UNPROTECT() when object is assigned to a list?
Hi,
I'm troubleshooting some native code on Windows that very occationally
(and semi-randomly) crashes R. Already looked at "everything", I just
want to double check that it is safe to UNPROTECT() allocated
variables as soon as they are assigned to, say, a PROTECTed list.
>From (R v2.3.0) Section 5.7.1 "Handling the effects of garbage
collection" in "Writing R
2013 Apr 01
2
Timing of SET_VECTOR_ELT
Assume a C program invoked by .Call, that returns a list.
Near the top of the program we allocate space for all the list elements. (It is my habit
to use "xyz2" for the name of the R object and "xyz" for the pointer to its contents.)
PROTECT(means2 = allocVector(REALSXP, nvar));
means = REAL(means2);
PROTECT(u2 = allocVector(REALSXP, nvar));
u =
2007 Aug 03
2
How to properly finalize external pointers?
Dear R .Call() insiders,
Can someone enlighten me how to properly finalize external pointers in C code (R-2.5.1 win)? What is the relation between R_ClearExternalPtr and the finalizer set in R_RegisterCFinalizer?
I succeeded registering a finalizer that works when an R object containing an external pointer is garbage collected. However, I have some difficulties figuring out how to do that in an
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
2009 Mar 30
1
Setting the names attribute of a list?
Hello,
I have created a vector with 2 elements(see code below)
I am calling this function many thousands of times (hundreds of
thousands) after some time
i get
*** caught segfault ***
address 0x5, cause 'memory not mapped'
However, if i dont set the R_NamesSymbol, I do not get any such error.
Am I doing this correctly?
Thank you
Saptarshi
==CODE===
// kxp and usar are two SEXP's
2005 Nov 07
3
R thread safe
Dear R-dev,
I would like to accelerate my R computation by using parallel OpenMP compilers
(e.g from Pathscale) on a 2-processor AMD server and I would like to know
whether R is a tread safe library. The main kernel of the OpenMP
parallelization is a C SEXP function that performs the computational routine in
parallel with:
*******************
SEXP example(SEXP list, SEXP expr, SEXP rho)
{
2006 Aug 21
1
return tree from .Call
Hello:
I was hoping to get some advice about how to return a tree (basically a
linked list -- with each node containing a parent, left, and right node
pointers) from a C routine back into R. Each node itself contains several
attributes (a double, a char *, an int, and a void * )
Initially I was thinking I could just return to R a SEXP containing a
pointer to the Root Node, but then realized
2007 Nov 16
4
Returning vectors of two different data types back to R environment (from C).
Hello,
Quick question.
I have written a C function - I would like to make it return two vectors to
the R environment - one STRSXP vector, and one INTSXP vector. Is this
possible/ easy to do using the API?
I looked, but could not find the answer to this question in the "Writing R
Extensions" guide.
Thanks very much for your help!
Charles
[[alternative HTML version deleted]]
2006 Dec 24
2
FW: Passing lists from R to C, extracting elements, and sending lists back again
Thank you to everyone who responded to my previous post regarding the integration into R of C programs that use external libraries. I have another issue that I simply have not been able to figure out using documentation, list archives, and so forth.
I have data that is stored in R lists. I would like to pass the list to C code using the .Call function, perform mathematical operations on the
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 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
2016 Oct 24
3
typo or stale info in qr man
man for `qr` says that the function uses LINPACK's DQRDC, while it in
fact uses DQRDC2.
```
The QR decomposition of the matrix as computed by LINPACK or LAPACK.
The components in the returned value correspond directly to the values
returned by DQRDC/DGEQP3/ZGEQP3
```
2014 Jun 26
1
using 2D array of SEXP for creating dataframe
Hi ,
For our production package i need to create a dataframein C . So I wrote
the following code
SEXP dfm ,head,df , dfint , dfStr,lsnm;
*SEXP valueVector[2];*
char *ab[3] = {"aa","vv","gy"};
int sn[3] ={99,89,12};
char *listnames[2] = {"int","string"};
int i,j;
//=============================
PROTECT(df = allocVector(VECSXP,2));
2003 Oct 03
1
allocating memory in a C module
Hi,
I'm using a package that has a number of formats. I have C code to
parse these formats the results of which are generally integer arrays.
I would like to utilize these modules in R rather than writing R code to
read in these files (and also to learn about R extensions).
Essentially what I want is to do something like this:
load_tsets <- function(t,c,p)
.C( "c_load_tsets",