Installing odbc package - r

I am trying to use the new RStudio Connection Pane to set up an ODBC connection. When I try to do this I get the error message:
Required package versions could not be found: odbc 1.1.1 is required but 1.0.1 is available
I have tried installing the latest odbc package by running:
devtools::install_github("r-dbi/odbc")
It runs for quite some time but not until the end. The last part of the log is:
Warning in file.copy(files, dest, overwrite = TRUE) : problem
copying .\odbc.dll to
C:\Users\Daniel.Thuresson\Documents\R\win-library\3.3\odbc\libs\x64\odbc.dll:
Permission denied
** R
** inst
** tests
** byte-compile and prepare package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
vI[[j]]) : there is no package called 'bit'
ERROR: lazy loading failed for package 'odbc'
* removing 'C:/Users/Daniel.Thuresson/Documents/R/win-library/3.3/odbc'
* restoring previous 'C:/Users/Daniel.Thuresson/Documents/R/win-library/3.3/odbc'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date
= TRUE) : problem copying C:\Users\Daniel.Thuresson\Documents\R\win-library\3.3\00LOCK-r-dbi-odbc-b3d159a\odbc\libs\x64\odbc.dll
to
C:\Users\Daniel.Thuresson\Documents\R\win-library\3.3\odbc\libs\x64\odbc.dll:
Permission denied
Error: Command failed (1)
In addition: Warning messages:
1: In value[3L] : object 'odbcListDrivers' not found
2: In value[3L] : object 'odbcListDrivers' not found
3: In value[3L] : object 'odbcListDrivers' not found
I am a noob when it comes to this. I have only used R for analyzing local data and never have had to connect to a database. I would very much appreciate if someone could help me solve this!

Related

WGCNA functions not found

I'm applying WGCNA to RNASeq data following this tutorial. For several functions it give me an error that the package functions are not found.
> sft <- pickSoftThreshold(normalized_counts,
+ dataIsExpr = TRUE,
+ corFnc = cor,
+ networkType = "signed"
+ )
Error in pickSoftThreshold(normalized_counts, dataIsExpr = TRUE, corFnc = cor, :
could not find function "pickSoftThreshold"
I tried to make sure that the package was called correctly, but when I called it the following error emerged:
> library(WGCNA)
Error: package or namespace load failed for ‘WGCNA’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘xfun’
In addition: Warning message:
package ‘WGCNA’ was built under R version 4.1.3
So I tried installing the package "xfun":
> install.packages("xfun")
Installing package into ‘C:/Users/me/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/xfun_0.31.zip'
Content type 'application/zip' length 401092 bytes (391 KB)
downloaded 391 KB
package ‘xfun’ successfully unpacked and MD5 sums checked
Error in install.packages : ERROR: failed to lock directory ‘C:\Users\me\Documents\R\win-library\4.1’ for modifying
Try removing ‘C:\Users\me\Documents\R\win-library\4.1/00LOCK’
I followed some threads that suggested trying the following code for the error:
> install.packages("xfun", dependencies = TRUE, INSTALL_opts = '--no-lock')
package ‘pkgbuild’ successfully unpacked and MD5 sums checked
Error in install.packages : ERROR: failed to lock directory ‘C:\Users\parnian\Documents\R\win-library\4.1’ for modifying
Try removing ‘C:\Users\me\Documents\R\win-library\4.1/00LOCK’
I don't know how to overcome these errors to be able to use WGCNA functions such as pickSoftThreshold(). Can you help me?
Go to your library folder: C:\Users\me\Documents\R\win-library\4.1/ and remove all folders beginning with 00LOCK
Restart R and then try to reinstall xfun and WGCNA

Can't install github package in RStudio: "Permission denied"

I wanted to run some code that uses the 'rethinking' library. As instructed there, I first installed rstan, which went fine, then typed
install_github("rmcelreath/rethinking")
The latter gives the errors:
Error: package or namespace load failed for 'ggplot2' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace 'ellipsis' 0.3.1 is being loaded, but >= 0.3.2 is required
Error: package 'ggplot2' could not be loaded
In addition: Warning messages:
1: package 'rstan' was built under R version 4.0.5
2: package 'StanHeaders' was built under R version 4.0.5
3: package 'ggplot2' was built under R version 4.0.5
Execution halted
ERROR: lazy loading failed for package 'rethinking'
* removing 'C:/Program Files/R/R-4.0.3/library/rethinking'
Warning messages:
1: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\curl\libs\x64\curl.dll to C:\Program Files\R\R-4.0.3\library\curl\libs\x64\curl.dll: Permission denied
2: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\ps\libs\x64\ps.dll to C:\Program Files\R\R-4.0.3\library\ps\libs\x64\ps.dll: Permission denied
3: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\ellipsis\libs\x64\ellipsis.dll to C:\Program Files\R\R-4.0.3\library\ellipsis\libs\x64\ellipsis.dll: Permission denied
4: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\digest\libs\x64\digest.dll to C:\Program Files\R\R-4.0.3\library\digest\libs\x64\digest.dll: Permission denied
5: In i.p(...) :
installation of package ‘C:/Users/User/AppData/Local/Temp/RtmpAfQQaY/file1268133e3024/rethinking_2.13.tar.gz’ had non-zero exit status
> source("~/.active-rstudio-document", echo=TRUE)
Indeed, if I try to run code from the library, I get:
> library(rethinking)
Error in library(rethinking) : there is no package called ‘rethinking’
I am running Rstudio 2021.09.0 as administrator, on Windows 10.
I also tried installing the library from the Packages|Install button, but that gives
> install.packages("rethinking")
Warning in install.packages :
package ‘rethinking’ is not available for this version of R
The solutions suggested here did not work for me. Any help would be appreciated!
EDIT: for solution, please see comments - thanks for the replies!

Deseq2 package: DESeqDataSetFromHTSeqCount not found

I have installed DESeq 2 and it gives this error message:
Error: package or namespace load failed for ‘DESeq2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘Rcpp’
I have then tried to install RCPP but it gives the following error message:
1 error generated.
make: *** [api.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp’
Warning in install.packages :
installation of package ‘Rcpp’ had non-zero exit status
I have updated everything I could, R and R studio as well as my mac but the error persists.
Therefore when I try to run the following function of DESeq2 I can't run it and it gives me the following error which I guess is due to not having Rcpp:
dds <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable,
+ directory = getwd(),
+ design= ~ replicate + condition )
Error in DESeqDataSetFromHTSeqCount(sampleTable = sampleTable, directory = getwd(), :
could not find function "DESeqDataSetFromHTSeqCount"
Any help or solution on how to solve this?
Thanks a lot!!
Alerie

Space in path name causing "Warning: invalid package" on install. R

When running R-3.4.4 (on Windows 7, RStudio):
install.packages("ggplot2", destdir = "C:/Program Files/R/R-3.4.4/library/temp")
I get the following warning (presumably from the space in the path):
installing the source package ‘ggplot2’
trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.2.1.tar.gz'
Content type 'application/x-gzip' length 3204655 bytes (3.1 MB)
downloaded 3.1 MB
Warning: invalid package 'C:/Program'
Warning: invalid package 'Files/R/R-3.4.4/library/temp/ggplot2_3.2.1.tar.gz'
Error: ERROR: no packages specified
In R CMD INSTALL
Warning in install.packages :
running command '"C:/Program Files/R/R-3.4.4/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.4.4\library" C:/Program Files/R/R-3.4.4/library/temp/ggplot2_3.2.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
Although, trying to circumvent it using:
install.packages("ggplot2", destdir = "C:/Temp")
leads to:
* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called 'pillar'
where
.libPaths()
[1] "C:/Program Files/R/R-3.4.4/library"
Again, trying to solve that warning with:
install.packages("pillar", destdir = "C:/Temp")
leads to
** testing if installed package can be loaded
Fatal error: cannot open file 'C:\Users\Mary': No such file or directory
The full path is C:\Users\Mary Surname\etc\etc... Which brings it back to the first problem where there is a space between "FirstName" and "Surname" in the path.
Any way to correct the incorrect interpretation of the space. Note, the download is fine but it falls over trying to find the zip file it had only just downloaded.

Problems loading the Swirl package

I was able to install the swirl package, but when I give the library (swirl) command, the following error appears:
Error: package or namespace load failed for ‘swirl’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘crayon’
So I try to install the crayon package and it appears:
* installing *source* package 'crayon' ...
** package 'crayon' successfully unpacked and MD5 sums checked
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Tams/Documents/R/win-library/3.4/crayon/DESCRIPTION': No such file or directory
Error in file(file, if (append) "a" else "w") :
it's not possible to open the conection
ERROR: installing package DESCRIPTION failed for package 'crayon'
* removing 'C:/Users/TAÍS/Documents/R/win-library/3.4/crayon'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Users\TAÍS\Documents\R\win-library\3.4" C:\Users\TAS~1\AppData\Local\Temp\Rtmpc9eX85/downloaded_packages/crayon_1.3.4.tar.gz' had status 1
Warning in install.packages :
installation of package ‘crayon’ had non-zero exit status
How can I solve this problem and load the swirl package?
Try loading it directly from Github and see if it solves the problem. You may want to restart your instance of R prior to this to ensure that all is right in the world.
devtools::install_github("r-lib/crayon")
library(crayon)

Resources