Displaying 20 results from an estimated 5000 matches similar to: "Calling C fn crashes (PR#4281)"
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
2008 Jul 18
0
Rcpp from C++
Hi Sri,
I haven't really elaborated on it having other stuff to prepare first, but as
far as I got you first assign data to a vector:
#include <R.h>
#include <Rinternals.h>
#undef R_INTERFACE_PTRS
#include <Rembedded.h>
#include "Rcpp.hpp"
#include <R_ext/Parse.h>
#include <Rinternals.h>
#include <Rdefines.h>
//assigning a vector
SEXP
2003 May 28
0
R_GlobalEnv
Hi,
I'm trying to access the current R global environment from
within C, using R_GlobalEnv.
In the example below, Rgui (R 1.7.0. Win2K) crashes when I try
to run assignValueToFooInR_GlobalEnv, but not when I run
assignValueToFooInRhoEnv with Rho=.GlobalEnv. Can anyone tell me why?
[ My motivation is that I want use defineVar to initialise a
workingEnvironment (corresponding to Value
2009 Aug 20
2
Problem using findVar( ) in combination with R's lazy evaluation
Hi All,
I have a few small questions about the usage of the C findVar( ) function
when used in C code called with '.Call'. In my case I create an R function
with an argument. This function calls some C code in which I use findVar( )
to retrieve the values from the argument. Ofcourse normally I would just
give the values as argument to .Call, but in my project I need to use
findVar for
2010 Aug 21
1
Speed improvement to evalList
I've been inspired to look at the R source code by some strange timing
results that I wrote about on my blog at radfordneal.wordpress.com
(see the posts on "Speeding up parentheses..." and "Two surprising
things...".
I discovered that the strange speed advantage of curly brackets over
parentheses is partially explained by an inefficiency in the evalList
and
2008 Jan 16
1
Pb with defineVar() example in the "Writing R Extensions" manual
Hi,
I'm wondering if this code from the "Writing R Extensions" manual
is really safe:
SEXP mkans(double x)
{
SEXP ans;
PROTECT(ans = allocVector(REALSXP, 1));
REAL(ans)[0] = x;
UNPROTECT(1);
return ans;
}
double feval(double x, SEXP f, SEXP rho)
{
defineVar(install("x"), mkans(x), rho);
2009 Nov 28
1
PROTECT and OCaml GC.
Hello.
In the writing of my OCaml-R binding, I'm sort of confused when it comes
to the use of the PROTECT and UNPROTECT macros.
Basically, I have C stub functions that are in charge of calling R for
everything. Here's a simple example:
> CAMLprim value r_findvar (value symbol) {
> /* The findVar function is defined in envir.c. It looks up a symbol
> in an environment.
2006 Sep 28
1
eval(SEXP fn,SEXP rho) in C++ code
Hi r-devel,
I am working on a R extension. I am writing the
function in C++, and in my function it is required a R
function object from the user. This R function object
will be evaluated thousand of times in my C++ code. I
generated the shared library and I loaded it on R. I
did several experiments in order to compare the speed
of my compiled code vs the speed of the equivalent
interpreted code.
2009 Sep 03
1
Running an expression 1MN times using embedded R
Hello,
I'm evaluating this expression
expression({ for(x in 1:5){ .Call('rh_status','x') }})
a million times from a program with R embedded in it. I have attached
reproducible code that crashes with
Program received signal SIGSEGV, Segmentation fault.
0x00002b499ca40a6e in R_gc_internal (size_needed=0) at memory.c:1309
1309 FORWARD_NODE(R_PPStack[i]);
Current language:
2007 Aug 16
0
call R function in c++ program
Hi all
I don't know if my message are correct in this forums.
I create a program in c++ who use statistical function. I want to execute
this function in R (in particular for use packages ade4, lattice,
bioconductor...)
Until now, my program work for simple function ("plot", "rnorm"...) but I
can't use library
My class are :
// in constructor
int argc = 1;
2013 Oct 16
1
Parallel R expression evaluations
Hi all,
I am using R-3.0.1 under Linux platform to embed R into my C++ code.
I am facing an error while executing more than 1 R-expressions parallelly.
I am executing round(X) and abs(X) parallelly on a set of 50 input rows
which resulted in segmentation fault after getting the following errors.
Error: unprotect_ptr: pointer not found
Error: argument to 'findVar' is not an environment
2007 Jan 18
0
Emulating a REPL in frontends
A common need in R frontends is to provide some sort of read, (parse),
evaluate, print loop. However, there are also a number of points where
frontends may want to differ from the standard REPL as available e.g. in
R_ReplDLLdo1().
First some thoughts on what is needed, and what is already there, or missing.
If you want to skip over this, a short summary is provided in the second
half, below
2005 Aug 17
2
About R variable references
Hello Group,
I could use an advice on how SEXP handles work. My aim is to implement a
system where I initially set a few global variables that are used for
communication between C and R code. Then I do some work with R code and
periodically call a function of my own that will update the system
state. Such a design is useful for many purposes (for GUIs to name one).
I am not entirely sure that R
2001 Apr 14
1
Postscript font bugs (and a suggestion) (PR#914)
Documentation and other bugs with postscript():
1. This code crashes R (it asks for a font that isn't there):
postscript()
plot(0:1,0:1)
text(0.5,0.5,'crash',font=6)
The bug appears to be in the FixupFont routine in plot.c; on line 236,
it checks that the font number is in the range 1..32. Later this
crashes PostScriptStringWidth in devPS.c, because only fonts numbered
1..5
2007 Mar 27
3
Use of 'defineVar' and 'install' in .Call
Dear all,
[system and version information below]
I am trying to modify a C function for finding the root of an
expression. The function is to be called from R as .Call with input
parameters:
f: expression for which we will find the root
guesses: interval for the solution
stol: tolerance
rho: environment
The original functions I use are:
SEXP mkans(double x) {
SEXP ans;
PROTECT(ans =
2007 Mar 27
3
Use of 'defineVar' and 'install' in .Call
Dear all,
[system and version information below]
I am trying to modify a C function for finding the root of an
expression. The function is to be called from R as .Call with input
parameters:
f: expression for which we will find the root
guesses: interval for the solution
stol: tolerance
rho: environment
The original functions I use are:
SEXP mkans(double x) {
SEXP ans;
PROTECT(ans =
2015 Aug 25
0
Child thread libR.so
Simon,
Ah, thank you! quiet right. For anyone searching for this in the
future, I changed my init fuction to:
---------- SNIP ----------------
void init_r() {
SEXP aperm_function;
/* this is our version of Rf_initEmbeddedR where we disable stack
checking */
const char *init_argv[] = {"MyFront", "--vanilla", "--slave"};
Rf_initialize_R(sizeof
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));
2009 Mar 19
1
.Internal
I was trying to find source for optimize and I ran across
function (f, interval, ..., lower = min(interval), upper = max(interval),
maximum = FALSE, tol = .Machine$double.eps^0.25)
{
if (maximum) {
val <- .Internal(fmin(function(arg) -f(arg, ...), lower,
upper, tol))
list(maximum = val, objective = f(val, ...))
}
else {
val <-
2009 May 26
1
passing "..." arguments to a function called by eval()
Hi everyone,
I am starting learn to call C code from within R. So far, I've been
trying toy problems to see if I can get them to work. One of the things
I'd like to do is pass an arbitrary R function to C, evaluate the value
in the C code using eval, and then return it. I also want to allow an
arbitrary number of arguments to the function using "...".
The code for my toy