Search code examples
rrcpp

Recover Rcpp source file


I successfully sourced a cpp file into the R environment using sourceCpp('my_cpp_code.cpp'), but I removed the 'my_cpp_code.cpp' by mistake. It is possible to recover the source code of my_cpp_code.cpp from the R environment?


Solution

  • The temporary directory of your R session (tempdir()) will contain a folder named sourceCpp-<architecture>->Rcpp-version> with sub-directories named sourcecpp_<random>. One of these will contain your code (plus the autogenerated code).