Displaying 20 results from an estimated 2000 matches similar to: "Getting Rcpp SEXP data in C++"
2011 Jan 30
1
SMA and EMA in package TTR
Hi,
Just wondering for the SMA and EMA in package TTR, is it possible to me to
code it so that, say if I need to calculate SMA (x, n=100), when the sample
size is less than 100, it will give me the SMA (x, k) where k is the sample
size of the data? Right now it only gives me an invalid n error.
Thanks!
[[alternative HTML version deleted]]
2013 May 14
2
invalid operands of types ‘SEXPREC*’ and ‘R_len_t’ to binary ‘operator/’ with Rcpp.
Dear R-Developers,
I just started learning how to use Rcpp. Earlier while using it, I
encountered an error as shown below:
file74d8254b96d4.cpp: In function ‘Rcpp::NumericVector
foo(Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::NumericVector,
Rcpp::Function, Rcpp::Function)’:
file74d8254b96d4.cpp:10: error: invalid operands of types ‘SEXPREC*’ and
‘R_len_t’ to binary ‘operator/’
make: ***
2015 Nov 03
1
Fwd: Rcpp sugar dpois
Hi. Here is a piece of cpp code.
It works, but I do not understand the rational for the use of
"R::dpois" to call the function dpois since in the examples I have always
found directly "dpois" or "Rcpp::dpois" that both do not work in my code.
Could anyone be so patient to explain me why should it be like that?
Thaks a lot, Enrico
#include <Rcpp.h>
using
2010 Aug 30
1
How to Remove Autocorrelation from Simple Moving Average time series
Hi R experts,
I am trying to remove autocorrelation from Simple Moving Average time series. I know that this can be done by using seasonal ARIMA like,
library(TTR)
data <- rnorm(252)
n=21
sma_data=SMA(data,n)
sma_data=sma_data[-1:-n]
acf(sma_data,length(sma_data))
2010 May 13
1
ggplot2: qplot won't work
I have a script running in the StatET Eclipse environment that
executes the ggplot2 command qplot in a function:
# Creates the plot
createPlot <- function(){
print("Lets plot!")
qplot(1:10, letters[1:10])
}
When executing the qplot line directly, it works. When executing the
script it does not open a window and it it does not plot. Is there
something important I have forgotten? I
2010 Mar 25
1
Error using Rcpp
Hi, Im not sure if this is the right place to post this. I am using Xubuntu
Karmic Koala and am trying to use the Rcpp package. I am testing it using a
simple code that takes in a vector and adds 1 to each element:
#include <Rcpp.h>
// This file takes in a vector and adds one to each entry
RcppExport SEXP addone(SEXP vec){
// create a local copy of vec
Rcpp::NumericVector
2011 Nov 11
3
Why does length("") == 1?
It seems obvious to me that the empty string "" is length 0.
cheers
Worik
[[alternative HTML version deleted]]
2009 Sep 24
2
Date formats in as.Date
I have trouble with this:
as.Date("Sep-1981", format="%b-%Y")
Returns "NA"
>From documentation for strftime
'%b' Abbreviated month name in the current locale. (Also matches
full name on input.)
'%Y' Year with century.
What am I doing wrong?
cheers
Worik
[[alternative HTML version deleted]]
2010 Jun 16
5
t-test problem
I have two pairs of related vectors
x1,y1
and
x2,y2
I wish to do a test for differences in means of x1 and y1, ditto x2 and y2.
I am getting odd results. I am not sure I am using 'pt' properly...
I have not included the raw vectors as they are long. I am interested if I
am using R properly...
> c(length(x1), length(y1), length(x2), length(y2))
[1] 3436 1619 2677 2378
First
2010 Dec 03
1
Error using Rcpp under windows xp
Hi,
I am a newbie to Rcpp packages, and got problems in having basic set-ups for
Rcpp under windows xp. Here is the list I have done.
1) installed Rtools and have no problem in compiling .c file.
2) installed Rcpp packages
3) set enviroment variables 'path' to make C:\Program
Files\R\R-2.12.0\library\Rcpp\include\ searchable
The sample C++ code I used is from the original website:
2011 Dec 13
1
Rcpp too good to be true?
Hello all,
I've been working on a package to do various things related to the
Conway-Maxwell-Poisson distribution and wanted to be able to make fast
random draws from the distribution. My R code was running quite slow so I
decided to give Rcpp a bash. I had used it before but only for extremely
basic stuff and always using inline. This time I decided to give making a
proper package a go.
2011 Apr 14
1
Rcpp segmentation faults on the simplest code
Hi all,
I'm new to R and Rcpp, and I'm trying to learn Rcpp with the simplest code
possible. My goal is to be able to call R functions from C++.
The code I'm trying to run is:
#include
#include
#include
#include
int main(int argc, char* argv[])
{
Rcpp::NumericVector v(1);
return 0;
}
It compiles and links fine. However, as soon as I run it, it segfaults. The
following is
2012 Oct 09
4
Modern Symbolic debugger for R programmes?
I think I am whistling in the wind, but is there a modern symbolic
debugger for R programmes?
I am working through some one else's code, thousands of lines, that
has the occasional bug in it, and a lot in my understanding of it.
I cannot make setBreakpoint or findLineNum work. I get "No source
refs found.". I am starting to loose my mind!
A debugger where I could set
2013 May 24
0
Rcpp with OpenMP - Need example Makevars
Dear R experts,
recently I started developing a Rcpp package "OpenMPTest".
Within that package I want to use OpenMP, as in the following code example:
// header file
#include <omp.h>
using namespace Rcpp ;
RcppExport SEXP testOpenMP( SEXP nThreads ) ;
// cpp file
SEXP testOpenMP( SEXP nThreads ) {
BEGIN_RCPP
NumericVector numberThreads = NumericVector( nThreads );
2011 Apr 15
1
[Rcpp-devel] Find number of elements less than some number: Elegant/fastsolution needed
On Thu, Apr 14, 2011 at 7:02 PM,
<rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
> I was able to write a very short C++ function using the Rcpp package
> that provided about a 1000-fold increase in speed relative to the best
> I could do in R. ?I don't have the script on this computer so I will
> post it tomorrow when I am back on the computer at the office.
>
>
2017 Dec 03
5
Rcpp, dyn.load and C++ problems
Hi,
I have written a small C++ function and compile it.
However in R I can't see the function I have defined in C++.
I have read some web-pages about Rcpp and C++ but it is a bit confusion
for me.
Anyway,
This is the C++-code:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
List compute_values_cpp(int totalPoints = 1e5, double angle_increment =
0.01, int radius =
2010 Jun 13
2
Scope and sapply
I am puzzled by the scope rules that apply with sapply.
If I want to modify a vector with sapply I tried...
N <- 10
vec <- vector(mode="numeric", length=N)
test <- function(i){
vec[i] <- i
}
sapply(1:N, test)
vec
but it not work.
How can this be done?
Worik
[[alternative HTML version deleted]]
2012 Apr 19
2
Trouble with [sv]apply
Friends
I clearly donot understand how sapply and vapply work.
What I have is a function that returns a matrix with an indeterminate
number of rows (some times zero) but a constant number of columns. I
cannot reliably use an apply function to assemble the matrices into a
matrix. I am not sure it is possible.
I can demonstrate the core of my confusion with this simple code.
A.f <-
2011 Oct 12
1
Error in Rcpp/inline (Windows XP)
Hi, everyone,
I am just trying to use Rcpp in my computer, and I would like to try a
simple example from website, but R keeps reporting me error. I am using
Windows XP, and has installed Rtools and GSI.
Here is the response:
> src = '
+ Rcpp::NumericVector xa(a);
+ Rcpp::NumericVector xb(b);
+ int n_xa = xa.size();
+ int n_xb = xb.size();
+
+ Rcpp::NumericVector xab(n_xa + n_xb - 1);
2017 Dec 03
0
Rcpp, dyn.load and C++ problems
.Call("compute_values_cpp")
Also, if you were passing arguments to the C++ function you would need to
declare the function differently.
Do a search on "Rcpp calling C++ functions from R"
HTH,
Eric
On Sun, Dec 3, 2017 at 3:06 AM, Martin M?ller Skarbiniks Pedersen <
traxplayer at gmail.com> wrote:
> Hi,
>
> I have written a small C++ function and compile it.