1

I am a R beginner and trying to run the code provided by the research paper "Contributions by Interest Groups to Lobbying Coalitions"(see http://michaeltheaney.com/wp-content/uploads/2018/04/Heaney_and_Leifeld_2018.pdf)
i encountered a sticky problem beyond my knowledge, so i want to ask for help.

here is the code:

    cpp.comember.strong <- cxxfunction(signature(mat = "matrix"), plugin = "Rcpp", 
        body = '
      IntegerMatrix mem = as<IntegerMatrix>(mat);
  int rows = mem.nrow();
  int cols = mem.ncol();
  Rcpp::NumericMatrix comemb = NumericMatrix(rows, cols);
  int realized;
  int possible;
  for (int i = 0; i < cols; i++) {
    for (int j = 0; j < rows; j++) {
      realized = 0;
      possible = 0;
      for (int k = 0; k < rows; k++) {
        for (int l = 0; l < cols; l++) {
          if (j != k && i != l && mem(j, i) == 1 && mem(k, i) == 1) {
            possible++;
            if (mem(k, l) == 1 && mem(j, l) == 1) {
              realized++;
            }
          }
        }
      }
      //std::cout << i << " " << j << " " << realized << " " << possible << "\\n";
      if (possible == 0.0) {
        comemb(j, i) = 0.0;
      } else {
        comemb(j, i) = double(realized) / double(possible);
      }
    }
  }
  return(wrap(comemb));
')

I get the following error:

`ERROR(s) during compilation: source code errors or compiler configuration errors!
make cmd is
  make -f "C:/PROGRA~1/R/R-4.0.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-4.0.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file460c720a370.dll" WIN=64 TCLBIN=64 OBJECTS="file460c720a370.o"

make would use
Warning message:
In system(paste(cmd, "-n")) : 'make' not found

Program source:
  1: 
  2: // includes from the plugin
  3: 
  4: #include <Rcpp.h>
  5: 
  6: 
  7: #ifndef BEGIN_RCPP
  8: #define BEGIN_RCPP
  9: #endif
 10: 
 11: #ifndef END_RCPP
 12: #define END_RCPP
 13: #endif
 14: 
 15: using namespace Rcpp;
 16: 
 17: // user includes
 18: 
 19: 
 20: // declarations
 21: extern "C" {
 22: SEXP file460c720a370( SEXP mat) ;
 23: }
 24: 
 25: // definition
 26: 
 27: SEXP file460c720a370( SEXP mat ){
 28: BEGIN_RCPP
 29: 
 30:  IntegerMatrix mem = as<IntegerMatrix>(mat);
 31:  int rows = mem.nrow();
 32:  int cols = mem.ncol();
 33:  Rcpp::NumericMatrix comemb = NumericMatrix(rows, cols);
 34:  int realized;
 35:  int possible;
 36:  for (int i = 0; i < cols; i++) {
 37:  for (int j = 0; j < rows; j++) {
 38:  realized = 0;
 39:  possible = 0;
 40:  for (int k = 0; k < rows; k++) {
 41:  for (int l = 0; l < cols; l++) {
 42:  if (j != k && i != l && mem(j, i) == 1 && mem(k, i) == 1) {
 43:  possible++;
 44:  if (mem(k, l) == 1 && mem(j, l) == 1) {
 45:  realized++;
 46:  }
 47:  }
 48:  }
 49:  }
 50:  //std::cout << i << " " << j << " " << realized << " " << possible << "\n";
 51:  if (possible == 0.0) {
 52:  comemb(j, i) = 0.0;
 53:  } else {
 54:  comemb(j, i) = double(realized) / double(possible);
 55:  }
 56:  }
 57:  }
 58:  return(wrap(comemb));
 59: 
 60: END_RCPP
 61: }
 62: 
 63: 

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Warning message:In system(cmd) : 'make' not found`

I'm running Windows 10. My sessionInfo is as follows:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 
[2] LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] MASS_7.3-53          lme4_1.1-25          Matrix_1.2-18       
 [4] reshape2_1.4.4       Rcpp_1.0.5           inline_0.3.16       
 [7] texreg_1.37.5        xergm_1.8.3          GERGM_0.13.0        
[10] rem_1.3.1            tnam_1.6.5           btergm_1.9.13       
[13] ggplot2_3.3.2        xergm.common_1.7.8   ergm_3.11.0         
[16] sna_2.6              statnet.common_4.4.1 network_1.16.1      

loaded via a namespace (and not attached):
 [1] RSiena_1.2-23      lattice_0.20-41    foreach_1.5.1     
 [4] rle_0.9.2          R6_2.4.1           plyr_1.8.6        
 [7] stats4_4.0.2       coda_0.19-4        httr_1.4.2        
[10] pillar_1.4.6       rlang_0.4.8        rstudioapi_0.11   
[13] minqa_1.2.4        vegan_2.5-7        nloptr_1.2.2.2    
[16] splines_4.0.2      statmod_1.4.35     stringr_1.4.0     
[19] igraph_1.2.6       munsell_0.5.0      compiler_4.0.2    
[22] pkgconfig_2.0.3    speedglm_0.3-2     mgcv_1.8-31       
[25] tcltk_4.0.2        tidyselect_1.1.0   tibble_3.0.4      
[28] lpSolve_5.6.15     codetools_0.2-16   permute_0.9-5     
[31] crayon_1.3.4       dplyr_1.0.2        withr_2.3.0       
[34] grid_4.0.2         nlme_3.1-148       gtable_0.3.0      
[37] lifecycle_0.2.0    magrittr_1.5       scales_1.1.1      
[40] RcppParallel_5.0.2 stringi_1.5.3      ROCR_1.0-11       
[43] doParallel_1.0.16  robustbase_0.93-6  ellipsis_0.3.1    
[46] generics_0.0.2     vctrs_0.3.4        boot_1.3-25       
[49] trust_0.1-8        iterators_1.0.13   tools_4.0.2       
[52] glue_1.4.2         DEoptimR_1.0-8     purrr_0.3.4       
[55] parallel_4.0.2     colorspace_1.4-1   cluster_2.1.
lx huo
  • 11
  • 1
  • 2
  • 3
    Read https://cran.r-project.org/bin/windows/Rtools/. Pay close attention to the second section titled *"Putting Rtools on the PATH"*. (This starts with "install Rtools40" if you don't have it already installed on your OS.) – r2evans Dec 31 '20 at 02:50
  • Candidate duplicate questions: https://stackoverflow.com/q/63020444/3358272, https://stackoverflow.com/q/62469777/3358272. – r2evans Dec 31 '20 at 02:54
  • 1
    thanks for your reply! it is the solution – lx huo Jan 02 '21 at 05:46

0 Answers0