Displaying 20 results from an estimated 2000 matches similar to: "Get the tail of a list in C"
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)
{
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
2008 Jan 04
1
Evaluating R expressions from C
I am currently puzzled by a passage in the R Extensions manual, section 5.10:
SEXP lapply(SEXP list, SEXP expr, SEXP rho)
{
R_len_t i, n = length(list);
SEXP ans;
if(!isNewList(list)) error("`list' must be a list");
if(!isEnvironment(rho)) error("`rho' should be an environment");
PROTECT(ans = allocVector(VECSXP, n));
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
2004 Jun 16
1
off topic: C/C++ codes for pseudo inverse
Hi,
I am looking for C/C++ codes for computing generalized
inverse of a matrix. Can anyone help me in this
regard?
Thanks,
Mahbub.
2010 Mar 11
1
Shrinking a List
Hello,
I create a VECSXP(call it A) with size N(~ 5000), i then proceed to
fill the elements and find out I don't need to fill more than
M (M<< N).
Thus if i return A to the user's R code, he/she will see a list of
length 5K of which N-M are NULLs.
To avoid this, I create a new VECSXP B of length M and /duplicate/ the
elements of A.
Since I do this often, it appears to be wasteful,
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
2010 Aug 26
2
Speeding up transpose
I've looked at how to speed up the transpose function in R
(ie, t(X)).
The existing code does the work with loops like the following:
for (i = 0; i < len; i++)
REAL(r)[i] = REAL(a)[(i / ncol) + (i % ncol) * nrow];
It seems a bit optimistic to expect a compiler to produce good code
from this. I've re-written these loops as follows:
for (i = 0, j = 0; i<len; i +=
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
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
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 =
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 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*
2007 Oct 18
3
append/concatenate an element to a list in C-language
dear people,
i need to code a function in C working in R and receives two R SEXP
objects as parameters, where one is a list and another is a vector of
integers:
void f(SEXP list, SEXP vector) {
...
return list;
}
and it should return the given list with the integer vector concatenated
at the end (as the last element of the list). the list can be really big
so i would not like to create a
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
2005 Nov 07
4
Time-measurement in milliseconds
Hi there
I'm loking for a time-measurement to measure time-differences in
milliseconds.
On my search, I only found the following:
- package "base": Sys.time()
-> only second-accuracy
- package "R.utils": System$currentTimeMillis()
-> returns integer of milliseconds, but accuracy is only whole
seconds too.
At the moment I run every bit of code to measure
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
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] =
2004 Mar 17
1
best methods for strings and structures?
I'm trying to generate an R interface for a library that's commonly used and
I'm currently writing wrapper functions for file i/o and return an object
(list?) that contains the elements of the C structure. For example, reading
a file that contains:
struct CONFIG_RECORD
{
char coeffs_filename[256];
char species_filename[256];
unsigned long
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