Displaying 20 results from an estimated 1000 matches similar to: "SEXPTYPEs"
2013 Mar 22
1
Why does typeof() modify an object's "named" field?
Hello,
Doing typeof() on an object appears to reset the "named" field in its
sxpinfo header to 2, which can change the way that subsequent
subassignment operations are carried out:
X <- 1:5e7
.Internal(inspect(X))
# @4eeb0008 13 INTSXP g0c7 [NAM(1)] (len=50000000, tl=0) 1,2,3,4,5,...
system.time(X[1] <- 9L)
# user system elapsed
# 0 0 0
typeof(X)
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
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]]
2013 Dec 16
1
External pointers and changing SEXPTYPE
Dear Developers,
I've been struggling through writing R extension in C. I've been using
an external pointer to store my data (please see sample below). I
encountered a very weird erroneous behaviour: when I tried to use my
external pointer to a structure holding several types of data,
including SEXPs, I discovered that SEXPs change their types between
returning from initialization
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*
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
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 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] =
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 Nov 26
1
dynamic lists at C level
Dear R-devel,
I am trying to do something similar to dynamic length lists in R, but
at C level.
In R, that would be rather trivial:
- determine the length of the list
- create the list object
- store the values for each component
- access value components by using "[["
At C level, for a single component where I need to store a vector of
length 5, I do:
int *p_result;
SEXP my_list =
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 +=
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
2005 Mar 16
1
returning NULL from .Call call
Dear R developers,
I've just encountered one "feature" of R-C extensions. If it is known, I
would be thankful for any hints why it works this way (I found the way
around, which is also mentioned here, but maybe it is not the best one).
If it is however unknown, it might be considered for a "wish list".
Consider a simple "aka" C function (the original
2009 Mar 23
1
incoherent treatment of NULL
somewhat related to a previous discussion [1] on how 'names<-' would
sometimes modify its argument in place, and sometimes produce a modified
copy without changing the original, here's another example of how it
becomes visible to the user when r makes or doesn't make a copy of an
object:
x = NULL
dput(x)
# NULL
class(x) = 'integer'
# error: invalid
2003 Oct 04
0
allocating memory in a C module (fwd)
I pressed ^X in the wrong window. Here's the right code:
Here's some code that does a pointless example
In C:
#include "Rinternals.h"
/* function takes no arguments and returns an object */
SEXP pie(){
int n;
SEXP alist, avector;
/* work out how long a list to return */
n = 2;
/* create the list */
PROTECT(alist = allocVector(VECSXP, n));
/* create the first
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
2013 Jul 13
2
missing PROTECT() in src/main/arithmetic.c
at lines 651 & 653 (integer_binary function):
if (code == DIVOP || code == POWOP)
ans = allocVector(REALSXP, n);
else
ans = allocVector(INTSXP, n);
There are calls to warningcall() later in the function, which can
trigger garbbage collection.
Looks like the typical scenario where it seemed pretty safe to not
PROTECT in the original version of the function but
2007 Apr 04
1
Accessing C++ code from R
Hi,
I am trying to use existing C++ code from R. I have no problems
compiling C code and using it in R, but with C++ I'm running into
problems.
Here's the compiler output:
Macintosh-10:~/Desktop/dissertation/Model - CPP version/R labguest$
g++ -I/Library/Frameworks/R.framework/Resources/include
-I/Library/Frameworks/R.framework/Resources/include/i386 *.cpp
In file included from
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",
2017 Feb 11
1
another fix for R crashes under enable-strict-barrier, lto, trunk@72156
I haven' t touched R for some 18 months, and so I have no idea if this is a recent problems or not; but it certainly did not segfault two years ago.
Since it has been crashing (segfault) under 'make check-all' for over a month, I reckon I'll have to look at it myself, to have it fixed.
I have been having the ' --enable-memory-profiling --enable-strict-barrier