23

I am trying to embed RInside to my application on win7 64-bit system but when I initialize an RInside:

Rin = new RInside(argc, argv);

the following message appears:

Error in loadNamespace(name) : there is no package called 'Rcpp'

This error only occurs with Windows.

micstr
  • 5,080
  • 8
  • 48
  • 76
chatzich
  • 1,083
  • 2
  • 11
  • 26

6 Answers6

44

I think you get that issue when your .libPaths() differ--in other words run the .libPaths() function to see the paths stored by R for its use. Then check where RInside is installed, and make sure Rcpp is installed there too. It is a setup issue.

In other words, it should work if you have Rcpp and RInside installed where the basic R libraries are. Otherwise you have to tell the (embedded) R session about the other location (and before it starts).

There are more Windows users on the list, so you could try asking on rcpp-devel.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • 14
    Very good -- and in that case it is customary to 'accept an answer' (click on the check mark you see next to it) as well as to 'upvote' it (click on the upward-facing triangle). You can vote on any question, you can accept only questions you asked. – Dirk Eddelbuettel May 31 '13 at 23:28
9
  1. First get your default library locations by command ".Library" in R.
  2. Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
  3. Unzip and copy folder "Rcpp" to your default library locations obtained from step1.

Now you are ready to install packages which have dependencies on Rcpp.

1

Dirk is right in this case, BUT if the .libPaths() does not work, then please also check if you have the latest packages.

I am posting this as an ancillary answer backup which I ran into with the shiny package backend switch of their code needing Rcpp!

In this case of getting the "no package" error message, I fixed it by:

  1. Selecting devtools package and then using this line below. (if you don't have devtools then get it with install.packages("devtools")

  2. devtools::install_github("rstudio/shiny")

The development version of the package handled this better, and added the package as a dependency.

Mods - I realize this is an answer to an old question, but I might help others not wasting an hour like I just did.

micstr
  • 5,080
  • 8
  • 48
  • 76
1

You might find it easy if the answers are for both R studio users and non R studio users.

R Studio users

  1. First get your default library locations by command ".Library" in R.
  2. Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
  3. Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.

Non R studio Users

  1. First get your default library locations by command ".libPath" in R.
  2. Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
  3. Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.
  • On Ubuntu, I had to use the command `.libPaths()` from inside an R session, or the command `R -e ".libPaths()"` from the terminal to get the library locations. – Chintan Pathak Aug 11 '20 at 18:40
0

I was also getting this error while trying to run the 'ggplot' function from the ggplot2 package. After trying the suggestions posted here and elsewhere (checking file paths, restarting R, clearing out my environment, etc.) and encountering several other cryptic error messages, it turned out that I needed to download the latest version of base R for Windows (v3.4.1) and update my version of R-Studio to the latest version also (v1.0.153).

After doing this my 'ggplot' function was working again and I was able to render my figure from R Studio without any further issues.

Paul Sochacki
  • 433
  • 6
  • 8
0

I was also getting this message when trying to use ggplot. I first updating both my R for Windows to 3.4.3. Then updating R studio to version 1.1.423; then, updating all of the packages and being sure to access the R version 3.4.3 from R studio, I still got the message. None of these things fixed the error. I was ready to give up until I noticed that I was calling library(ggplot) and had ggplot::ggplot in my code. THIS WAS THE PROBLEM. I changed it to library(ggplot2) and the instance to ggplot2::ggplot(...). THIS FIXEd the problems.