As a part of utilizing network data drawn at random before further processing, I am trying to call a couple of functions from the igraph package at the beginning of each iteration. The code I use is as follows:
#define ARMA_64BIT_WORD#include <RcppArmadillo.h> // [[Rcpp::depends(RcppArmadillo)]]// [[Rcpp::plugins(cpp11)]] using namespace Rcpp; using arma::sp_mat; // [[Rcpp::export]] sp_mat adj_mat(int n, double p) { Environment igraph("package:igraph"); Function game_er = igraph["erdos.renyi.game"]; Function get_adjacency = igraph["get.adjacency"]; List g = game_er(Named("n", n), Named("p", p)); NumericMatrix A_m = get_adjacency(Named("g", g)); sp_mat A = as<sp_mat>(A_m); return A;} /*** R set.seed(20130810) library(igraph) adj_mat(100, 0.5)*/ So, while the C++ compiles without warnings, the following error is thrown: > sourceCpp("Hooking-R-in-cpp.cpp") > set.seed(20130810) > library(igraph) > adj_mat(100, 0.5) Error in adj_mat(100, 0.5) : Not compatible with requested type: [type=S4; target=double]. >From the error it looks like I am passing a S4 class to a double? Where is the error?
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel