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?
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).
Maybe. sourceCpp() has a cacheDir argument (defaulting to getOption("rcpp.cache.dir", tempdir())) that specifies a location under which intermediate files, including the original source file, are saved. If the directory hasn't been cleaned up, you should find a folder there named "sourceCpp-<platform-info>" and under there, directories for each sourceCpp call you have done: these will contain the original file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With