I tried several ways on loading few specific packages inside my script.R
to run the script in terminal by typing ./Rscript script.R
. There is no problem with the script but I get an error when I want to load a package e,g tidyverse
.
Error: package or namespace load failed for ‘tidyverse’ in rbind(info, getNamespaceInfo(env, "S3methods")):
number of columns of matrices must match (see arg 2)
In addition: Warning message:
package ‘tidyverse’ was built under R version 3.6.0
Based on this link Installing a package in R inside a script I tried to find the location of the library by typing .libPaths()
in Rstudio then I gave the path to load the package inside the script.R
by typing
library(tidyverse,lib.loc="/Library/Frameworks/R.framework/Versions/3.6/Resources/library")
Again I get the same error. Could you please mention where is the mistake happening? Thanks