Displaying 20 results from an estimated 5000 matches similar to: "inline C/C++ in R: question and suggestion"
2007 Feb 13
2
anyone has C++ STL classes stability issue if used with R
Hello,
is there any one who uses C++ STL classes when programming shared libs
for R and has had any problems with STL?
In the very simple example below I am constantly getting segfaults when
trying to populate the queue. The segfault occurs at what looks like a
random index in the loop when pushing another element to the queue.
Reproduced on 4 machines. Object x is an Image as in EBImage,
2007 Oct 05
1
Sklyar's inline package: how to return a list?
Hi,
Below I have a mickey-mouse example using Oleg Sklyar's wonderful inline package.
The question I have is, how do I return multiple values, say in a list?
Inside the C code, I've also calculated 'sum'. How do I return this along with 'res'?
Ultimately, I want to return multiple matrix results. Thanks in advance for any code snipplets/advice!
Regards,
Ken
#
2015 Aug 21
3
unset() function?
Does R have a function like the S/S++ unset() function?
unset(name) would remove 'name' from the current evaluation
frame and return its value. It allowed you to safely avoid
some memory copying when calling .C or .Call.
E.g., suppose you had C code like
#include <R.h>
#include <Rinternals.h>
SEXP add1(SEXP pX)
{
int nProtected = 0;
int n = Rf_length(pX);
2013 Aug 27
1
Error in simulation. NAN
Hi all,
im triyng to implement a bayesian model with R and c++.
I have a strange problem. I can't reproduce the error with a small
script and then i post the original one.
The problem is after the line
for(MCMC_iter2=0;MCMC_iter2<thin;MCMC_iter2++)
For the first 34 iterations all work fine, after, all the simulations
of mu_acc_P return an "nan". If i delete the line
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
2004 Jun 22
3
[Q] GET_DIM() crash on Windows only
I have the following contrived code in package format.
On Solaris and Mac OS X, code runs just fine. On Windows,
it crashes the R environment with the "Send Bug Report"
dialog. I tried R 1.8.1 (Win2K) and R 1.9 (WinXP) binaries
with the same result. PCs otherwise appear properly
configured for creating R packages. Anything blatantly
wrong? Suggestions?
TIA
Relevant files from package
2015 Feb 05
2
Invalid read of size 8
Hi,
I have a R program that call a C function. I define a vector of pointer as
int nLC=3;
int pownLC = nLC*nLC
double *MatCovExtra[nT+1];
for(k=0;k<K+1;k++)
{
MatCovExtra[k] = (double*)R_alloc(pownLC, sizeof(double));
}
where nT>K. Then i put some values on the vector associated with the
pointer:
for(k=0;k<K+1;k++)
{
for(i=0;i<nLC;i++)
2012 Dec 06
1
Use .Call interface
Hi
I've written the following program:
#include <R.h>
#include <Rdefines.h>
#include "Projector.h"
SEXP Projector2(SEXP L, SEXP G, SEXP W, SEXP xymod, SEXP modif){
int nprot=0;
PROTECT(L=AS_NUMERIC(L));nprot++;
PROTECT(G=AS_NUMERIC(G));nprot++;
PROTECT(W=AS_NUMERIC(W));nprot++;
PROTECT(xymod=AS_INTEGER(xymod));nprot++;
PROTECT(modif=AS_NUMERIC(modif));nprot++;
2008 Feb 12
4
assigning NULLs to elements of a list
Dear developers:
I have just came across an (unexpected to me) behaviour of lists when
assigning NULLs to list elements. I understand that a NULL is a valid R
object, thus assigning a NULL to a list element should yield exactly the
same result as assigning any other object. So I was surprised when
assigning a NULL in fact removed the element from the list. Is this an
intended behaviour? If
2008 Apr 15
1
by inconsistently strips class - with fix
summary:
The function 'by' inconsistently strips class from the data to which
it is applied.
quick reason:
tapply strips class when simplify is set to TRUE (the default) due to
the class stripping behaviour of unlist.
quick answer:
This can be fixed by invoking tapply with simplify=FALSE, or changing
tapply to use do.call(c instead of unlist
executable example:
2013 Apr 09
2
Behaviors of diag() with character vector in R 3.0.0
Dear all,
According to CHANGES IN R 3.0.0:
o diag() as used to generate a diagonal matrix has been re-written
in C for speed and less memory usage. It now forces the result
to be numeric in the case diag(x) since it is said to have 'zero
off-diagonal entries'.
diag(x) does not work for character vector in R 3.0.0 any more. For example,
v <- c("a",
2009 Dec 22
0
Rcpp 0.7.0: R/C++ integration now even easier
Rcpp version 0.7.0 went onto CRAN this weekend. The key new features are
o inline support, taken from Oleg Sklyar's neat inline package and
adapted/extented to support Rcpp as well as external libraries
(see below for an example); this even works on Windows (provided you
have Rtools installed and configured);
o addition of a new simple type RcppSexp for importing or
2009 Dec 22
0
Rcpp 0.7.0: R/C++ integration now even easier
Rcpp version 0.7.0 went onto CRAN this weekend. The key new features are
o inline support, taken from Oleg Sklyar's neat inline package and
adapted/extented to support Rcpp as well as external libraries
(see below for an example); this even works on Windows (provided you
have Rtools installed and configured);
o addition of a new simple type RcppSexp for importing or
2015 Aug 22
0
unset() function?
This wouldn't actually work at present as evaluating a promise always
sets NAMED to 2. With reference counting it would work so might be
worth considering when we switch.
Going forward it would be best to use MAYBE_REFERENCED to test whether
a duplicate is needed -- this macro is defined appropriately whether R
is compiled to use NAMED or reference counting.
Best,
luke
On Fri, 21 Aug 2015,
2009 Apr 13
2
Gameguard ruins wine?
A little quote from the official cabal forums:
> Playing Cabal on linux is impossible thanks to gameguard, WINE (or Cedega) cannot correctly emulate the environment needed for gameguard to run which causes Cabal to exit with an error. You should check the WINE (and Cedega) websites for other people views/experiences trying to run any gameguard protected game on linux, none of them work.
>
2003 May 21
2
moving onto returning a data.frame?
I've been studying some of the code and I'm still a little shakey on the
proper method for returning a data.frame from a C function (which is my
ultimate goal here). I've started some code that I've "stolen" from the
archives and I'm running into crashes, etc. I've been trying to gleen some
insight from the src/main/scan.c file and didn't find many comments in
2006 Dec 02
2
nonlinear quantile regression
Hello, I?m with a problem in using nonlinear quantile regression, the
function nlrq.
I want to do a quantile regression o nonlinear function in the form
a*log(x)-b, the coefficients ?a? and ?b? is my objective. I try to use the
command:
funx <- function(x,a,b){
res <- a*log(x)-b
res
}
Dat.nlrq <- nlrq(y ~ funx(x, a, b), data=Dat, tau=0.25, trace=TRUE)
But a can?t solve de problem,
2007 Dec 10
2
bug in by.data.frame, R-2.6.1 (PR#10506)
by() fails for 1-column matrices and dataframes:
X <- data.frame(a=1:10)
g <- gl(2,5)
by(X, g, colMeans)
Suggested fix:
--- by-old.R 2007-12-10 15:26:22.501086600 +0100
+++ by.R 2007-12-10 15:25:58.390477200 +0100
@@ -26,7 +26,7 @@
IND[[1]] <- INDICES
names(IND) <- deparse(substitute(INDICES))[1]
} else IND <- INDICES
- FUNx <-
2003 Jun 23
3
FW: S4 classes, creating in C
I am using C code to create an S4 object based on Douglas Bates's example
in his lecture notes on
<http://www.ci.tuwien.ac.at/Conferences/DSC-2003/Tutorials/RExtensions/slide
s.pdf>
http://www.ci.tuwien.ac.at/Conferences/DSC-2003/Tutorials/RExtensions/slides
.pdf
e.g.
SEXP La_DGE_dc(SEXP A)
{
SEXP aa = PROTECT(duplicate(A));
SEXP adims, pivot, val;
int
2010 Sep 13
2
value returned by by()
Hi,
I noticed that by() returns an object of class 'by', regardless of what
its argument 'simplify' is. ?by says that it always returns a list if
simplify=FALSE, yet by.data.frame shows:
---<--------------------cut here---------------start------------------->---
function (data, INDICES, FUN, ..., simplify = TRUE)
{
if (!is.list(INDICES)) {
IND <-