Displaying 20 results from an estimated 6000 matches similar to: "returning NULL from .Call call"
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 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
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] =
2012 Sep 15
1
Question about copying arguments in C.
Hi List,
I'd imagine this is a question that has been answered before, but I
can't seem to track it down, sorry for the duplication if it has.
I am writing an interface for a C library and want to return an S4
class from the 'constructing' method. One of the slots of the argument
to be returned will be filled with one of the arguments passed to the
function. My question is about
2020 Sep 11
4
Garbage collection of seemingly PROTECTed pairlist
I want to write an R function using R's C interface that takes a 2-column
matrix of increasing, non-overlapping integer intervals and returns a list
with those intervals plus some added intervals, such that there are no
gaps. For example, it should take the matrix rbind(c(5L, 6L), c(7L, 10L),
c(20L, 30L)) and return list(c(5L, 6L), c(7L, 10L), c(11L, 19L), c(20L,
30L)). Because the output is
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
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
2010 Apr 14
2
Why no race condition when returning UNPROTECT-ed memory from C?
Consider the C (or C++) code called from the .Call interface:
SEXP foo() {
SEXP *p = PROTECT(allocVector(REALSXP, 10));
...
UNPROTECT(1);
return p;
}
Why is there no danger that the allocated memory will be garbage
collected after the UNPROTECT, but before the return of p?
I have used code like this for some time and have never had a
problem, but I'm not sure if/why it is guaranteed
2008 Apr 05
2
Adding a Matrix Exponentiation Operator
Hi all
I recently started to write a matrix exponentiation operator for R (by
adding a new operator definition to names.c, and adding the following code
to arrays.c). It is not finished yet, but I would like to solicit some
comments, as there are a few areas of R's internals that I am still feeling
my way around.
Firstly:
1) Would there be interest in adding a new operator %^% that performs
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
2008 Mar 05
1
SEXP size management.
Hi,
Trying to decrease the size of a SEXP variable without reassigning
values individually in a loop.
So far, I've tried using Realloc, as the follow source demonstrates:
SEXP dothis() {
SEXP Rblah;
PROTECT(Rblah = NEW_INTEGER(6));
int* blah = INTEGER(Rblah);
blah[0] = 1;
blah[1] = 2;
blah[2] = 3;
Realloc(Rblah, 3, INTEGER);
UNPROTECT(1);
return(Rblah);
}
According to the
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
2014 Mar 05
1
[PATCH] Code coverage support proof of concept
Hello,
I submit a patch for review that implements code coverage tracing in
the R interpreter.
It records the lines that are actually executed and their associated
frequency for which srcref information is available.
I perfectly understands that this patch will not make its way inside R
as it is, that they are many concerns of stability, compatibility,
maintenance and so on.
I would like to have
2007 Jan 19
5
Problem with C extension
Hello,
I try to write an extension in C, to get a faster functions.
Therefore I have to add an element (vector) to a vector. The command in
R is very simple: x = c(x,a)
But in C I have the problem to reallocate my vector for getting more
space. Everything I tried, I get a "Segmentation fault".
So, how can I combine two vectors in C and give the result back to R
(return(x))?
Thanks
2013 Apr 17
1
stack imbalance in max.col for non-real matrices
It's tough to reliably reproduce, but I often get stack imbalance warnings
when calling max.col() on non-real/double matrix. The code is conditionally
PROTECTing but not incrementing its nprot counter for the eventual
UNPROTECT. Pretty sure this would fix (but I haven't tested it):
Index: array.c
===================================================================
--- array.c (revision
2005 Jul 15
3
Passing character strings from C code to R
Hi,
I have a C code which produces array of integers and potentially a string,
and I have problems passing the string out. Here is the relevant part of the
code:
1 PROTECT(Ret = allocVector(INTSXP, n));
2 ret = (int*) INTEGER(Ret); /* get pointer to R's Ret */
3 for(i=0; i<n; i++) ret[i] = data[i];
4 Free(data);
5 i=1;
6 if (comment) { // comment was found
7 n
2005 Jul 15
3
Passing character strings from C code to R
Hi,
I have a C code which produces array of integers and potentially a string,
and I have problems passing the string out. Here is the relevant part of the
code:
1 PROTECT(Ret = allocVector(INTSXP, n));
2 ret = (int*) INTEGER(Ret); /* get pointer to R's Ret */
3 for(i=0; i<n; i++) ret[i] = data[i];
4 Free(data);
5 i=1;
6 if (comment) { // comment was found
7 n
2009 Jan 27
1
uninitialised value in R (PR#13476)
Hi,
I get an "Conditional jump or move depends on uninitialised value(s)"
from valgrind when using 'solve' in combination with some simple
C-code. (I did not use other functions of R besides 'solve'.)
In detail: running
R --vanilla -d "valgrind --tool=memcheck --memcheck:leak-check=yes
--num-callers=20 "
and calling
.Call("XXX")
nd <- 3
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 02
1
internal copying in R (soon to be released R-3.1.0
Dear core group,
Which operation in R guarantees to get a true copy of an atomic vector,
not just a second symbol pointing to the same shared memory?
y <- x[]
#?
y <- x
y[1] <- y[1]
#?
Is there any function that returns its argument as a non-shared atomic
but only copies if the argument was shared?
Given an atomic vector x, what is the best official way to find out
whether other