Installation issues of causalimpact in R - r

I followed this instruction from google website about installing causalimpact:
install.packages("devtools")*
library(devtools)
devtools::install_github("google/CausalImpact")
These codes however gives the following error:
Warning: package 'xts' was built under R version 3.2.5
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()),
versionCheck = vI[[j]]) : there is no package called 'Rcpp'
ERROR: lazy loading failed for package 'CausalImpact'
removing
'C:/Users/grace/Documents/R/R-3.2.4revised/library/CausalImpact'
Error: Command failed (1)**
Has anyone encountered this problem and can you give the solution?

I had the same problem. Following code solved it:
install.packages("devtools")*
library(devtools)
install.packages("bsts")
install.packages("xts")
library("bsts")
library("xts")
install.packages("DBI")
library("DBI")
install.packages("Rcpp")
library("Rcpp")
install.packages("magrittr")
library("magrittr")
install.packages("tibble")
library("tibble")
install.packages("gtable")
library("gtable")
install.packages("scales")
library("scales")
devtools::install_github("google/CausalImpact", force = TRUE)
The problem was that some libraries were not installed and they are required for Causal impact package.

Related

impossible to find the function "ggplot"

I am having problems with ggplot, getting the above error message.See full error message below after running library(ggplot2):
Error: package or namespace load failed for 'ggplot2' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
'vctrs' package 0.3.6 is already loaded, but >= 0.3.8 is required
Also: Warning message:
package 'ggplot2' was compiled with R 4.0.5
I have tried removing the package and then reinstalling it with dependencies. Nothing seems to work. The error seems to have been triggered when I tried to do an install of the ggflags package from Github, the package info states that it is a ggplot extension. Please give me an idea of how to fix this because I use ggplot for all data viz in R
Try the following shotgun-approach, as I suspect you are missing relevant packages,
# remove packages
remove.packages("tidyverse")
# reinstall
install.packages("tidyverse", dependencies = TRUE)
If this does not work, you should post your sessionInfo() in your post.

md.pattern() does not work after library(mice)

I just wanted to learn how to deal with missing value. I found the mice package, but if I run install.package and library R cannot find md.pattern. Does anybody know why?
install.packages("mice")
library(mice)
md.pattern(data)
Error in md.pattern(data) : could not find function "md.pattern"
library(mice)
Loading required package: lattice
Error: package or namespace load failed for ‘mice’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘minqa’
In addition: Warning message:
package ‘mice’ was built under R version 3.4.4
Search mice from the part where we installed all packages and ☑️mice from the packages .it will work.

R caret install error

library(caret)
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
object 'vI' not found
In addition: Warning message:
package ‘caret’ was built under R version 3.3.3
Error: package or namespace load failed for ‘caret’
I tried everything from re-installing R to deleting all the library folder but nothing helps.
At first, you need to install package lattice and ggplot2. Then install the caret package.
or, You can use the devtools library for installing the caret package.
install.packages("devtools")
library(devtools)
install_cran("caret")

Error using library(caret) in RStudio

I have been trying to use caret library for a simple ML application. I am using the latest versions of R (3.4.3) and RStudio (1.1.414). Here is my approach
install.packages("caret",repos = "http://cran.r-project.org", dependencies = c("Depends", "Imports", "Suggests"))
when I run the code library(caret) I get the following error
Error: package or namespace load failed for ‘caret’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘gower’
Now I went forward and installed the packages that it suggests one by one i.e., DEoptimR, gower, etc. This list never ends as once I install a package it will ask for another package. I am so frustrated. I have literally looked up in every forum but it did not solve my problem. I am not sure why the code install.package does not install all the required packages even though I ask explicitly to do so. when I check .libPaths() I can see it has access to both my library directories
[1] "C:/Users/omid/Documents/R/win-library/3.4"
[2] "C:/Program Files/R/R-3.4.3/library"
would anyone be able to help please?
Edit 1:
install.packages("caret",repos = "https://cran.r-project.org", dependencies = c("Depends", "Imports"))
Installing package into ‘C:/Users/omidm/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/bin/windows/contrib/3.4/caret_6.0-78.zip'
Content type 'application/zip' length 5155777 bytes (4.9 MB)
downloaded 4.9 MB
package ‘caret’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\omidm\AppData\Local\Temp\RtmpGuZ1vH\downloaded_packages
library(caret)
Loading required package: lattice
Loading required package: ggplot2
Error: package or namespace load failed for ‘caret’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘gower’
I also uninstalled R and RStudio and installed them again. Still getting the same error.
Solved:
I managed to solve this issue somehow, however, I am still not sure how. here is what I did
Open R GUI (not RStudio) and run:
install.packages("installr") # install
installr::updateR() # updating R
type q() to exit and then open RStudio. Go to Packages and Update all packages
Install package caret as per comments from #chinsoon and #Ronald
install.packages("caret", dependencies=c("Depends", "Imports"))
if you still get an error about any package just install that one. It will not ask for any other packages as you have removed "Suggest" from dependencies. Hope this manages to solve some people's problem.
Easy and simply:
install.packages("gower")
library(caret)
omg! yes ive been trying to find a solution for days! basically install anything it asks. I had to do the following
install.packages("gower")
library(caret)
Error: package or namespace load failed for ‘caret’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘hardhat’
install.packages("hardhat")
library(caret)
Error: package or namespace load failed for ‘caret’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘parallelly’
install.packages("parallelly")
then ran library(caret) and it worked

Installing Caret and ggplot2 packages in R 3.2.5

I've just installed a new version of R studio 3.2.5 that way I can install packages caret and ggplot2 however I always come across the same errors and not exactly sure where the problem is.
library(caret)
Loading required package: lattice
Loading required package: ggplot2
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
Error: package ‘ggplot2’ could not be loaded**
After this message I've install.packages("ggplot2")
and this shows up
library(ggplot2)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
Error: package or namespace load failed for ‘ggplot2’**
Does anyone have any suggestions?
try this
install.packages("ggplot2", dependencies = TRUE)
I have also got the same error and i tried many ways given in various solutions.
one solution which worked is
install.packages("stringi")
Then it many give errors stating some of the dependent libraries are missing.
Install those libraries, it will work.

Resources