Displaying 20 results from an estimated 3000 matches similar to: "Shrinking a List"
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 Sep 20
1
Return a list from a .Call but segfaults
Hello,
I call a function via .Call passing to it a raw vector(D) and an
integer(I)
The vector is a series K1,KData1, V1,VData1, K2, KData2, ...
where the integer K1 is the length of Data1 and similarly for Ki (wrt
Datai)(similarly for V*) There 2*I such pairs( (Ki,KDatai), (Vi,VDatai))
The numbers Ki(and Vi) are written in network order.
I am returning a list of I elements each element a
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
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));
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)
{
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
2018 May 08
2
unlist errors on a nested list of empty lists
On 08/05/2018 2:58 PM, Duncan Murdoch wrote:
> On 08/05/2018 1:48 PM, Steven Nydick wrote:
>> Reproducible example:
>>
>> x <- list(list(list(), list()))
>> unlist(x)
>>
>> *> Error in as.character.factor(x) : malformed factor*
>
> The error comes from the line
>
> structure(res, levels = lv, names = nm, class = "factor")
>
2007 May 29
1
Use of Rf_duplicate
First, thanks to those of you who responded to my previous post about my
code that was taking longer and longer to process. After following your
suggestions, and I now thinking that the problem was some calls to
Rf_duplicate in my C code.
So I'm hoping I could get some clarification on what Rf_duplicate actually
does. What is the real difference between
PROTECT(y=x); and
PROTECT (y =
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 +=
2013 Jul 05
1
Get the tail of a list in C
Hi,
I am write R extensions in C. Now I have a VECSXP variable, so how can I get
the tail of it (all but the first one) as a new VECSXP. I tried CDR(), but
it gives error.
Thanks.
--
View this message in context: http://r.789695.n4.nabble.com/Get-the-tail-of-a-list-in-C-tp4670900.html
Sent from the R devel mailing list archive at Nabble.com.
2018 May 09
2
unlist errors on a nested list of empty lists
On 08/05/2018 4:50 PM, Steven Nydick wrote:
> It also does the same thing if the factor is not on the first level of
> the list, which seems to be due to the fact that the islistfactor is
> recursive, but if a list is a list-factor, the first level lists are
> coerced into character strings.
>
> > x <- list(list(factor(LETTERS[1])))
> > unlist(x)
> Error in
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
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
2007 Jun 21
2
segfault during cbind
The following code results in a seg fault.
> sessionInfo()
R version 2.6.0 Under development (unstable) (2007-06-21 r42013)
x86_64-unknown-linux-gnu
locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics
2009 Jan 05
1
can't get names of R_env
Hi,
I'm quite knew in R, so I might not have the R specific jargon.
But here is my problem,
I'm trying to access and use variabels given by a function environment,
more specifically the rho in do_optim in src/main/optim.c
According to the documentation
http://cran.r-project.org/doc/manuals/R-ints.html#The-_0027data_0027
the envsxp is defined as a tagged pairlist.
"ENVSXP: Pointers
2010 Sep 08
0
Correction to vec-subset speed patch
I found a bug in one of the fourteen speed patches I posted, namely in
patch-vec-subset. I've fixed this (I now see one does need to
duplicate index vectors sometimes, though one can avoid it most of the
time). I also split this patch in two, since it really has two
different and independent parts. The patch-vec-subset patch now has
only some straightforward (locally-checkable) speedups for
2005 Sep 18
0
Updated rawConnection() patch
Here's an update of my rawConnection() implementation. In addition to
providing a raw version of textConnection(), this fixes two existing
issues with textConnection(): one is that the current textConnection()
implementation carries around unprotected SEXP pointers, the other is
a performance problem due to prolific copying of the output buffer as
output is accumulated line by line.
This new
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.
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
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