ERROR installing ggbiplot

Hi, Im newly using R. I need to instal ggbiplot and get this error message. What is rlang and how to solve this error?

Thanks in advance

install_github("vqv/ggbiplot")
Downloading GitHub repo vqv/ggbiplot@master
Installing 1 packages: rlang
Installing package into ‘C:/Users/Agathe/Documents/packrat/lib/x86_64-w64-mingw32/3.5.1’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rlang_0.3.1.zip'
Content type 'application/zip' length 1079739 bytes (1.0 MB)
downloaded 1.0 MB

package ‘rlang’ successfully unpacked and MD5 sums checked
Error: (converted from warning) cannot remove prior installation of package ‘rlang’`

It could mean rlang was loaded when you tried this new installation and something went wrong. You could

  1. Start a new clean session
  2. Install rlang from CRAN again
  3. Restart you session to get a clean one again
  4. install ggbiplot from Github

You have several questions like that on the community that you could be inspired from

1 Like

Thanks cderv,
Ive tried the steps you suggested, and got another ERROR:

> install_github("vqv/ggbiplot")
Downloading GitHub repo vqv/ggbiplot@master
√  checking for file 'C:\Users\Agathe\AppData\Local\Temp\RtmpINRX6Y\remotesb186494737f\vqv-ggbiplot-7325e88/DESCRIPTION' ...
-  preparing 'ggbiplot':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  looking to see if a 'data/datalist' file should be added
-  building 'ggbiplot_0.55.tar.gz'
   
Installing package into ‘C:/Users/Agathe/Documents/packrat/lib/x86_64-w64-mingw32/3.5.1’
(as ‘lib’ is unspecified)
* installing *source* package 'ggbiplot' ...
** R
** data
** byte-compile and prepare package for lazy loading
Warning: package 'ggplot2' was built under R version 3.5.2
Warning: package 'plyr' was built under R version 3.5.2
Warning: package 'scales' was built under R version 3.5.2
** help
*** installing help indices
  converting help for package 'ggbiplot'
    finding HTML links ... done
    ggbiplot                                html  
    ggscreeplot                             html  
    wine                                    html  
** building package indices
** testing if installed package can be loaded
*** arch - i386
**Error in file(filename, "r", encoding = encoding) : **
**  cannot open the connection**
**Calls: source -> file**
**In addition: Warning message:**
**In file(filename, "r", encoding = encoding) :**
**  cannot open file 'packrat/init.R': No such file or directory**
**Execution halted**
*** arch - x64
Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
Calls: source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'packrat/init.R': No such file or directory
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Users/Agathe/Documents/packrat/lib/x86_64-w64-mingw32/3.5.1/ggbiplot'
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/Agathe/AppData/Local/Temp/RtmpINRX6Y/fileb184697b8d/ggbiplot_0.55.tar.gz’ had non-zero exit status

Can you help?
Agathe

Can you confirm if you are working in a packrat project ?
I see packrat in the path to the :package: but not inside a project, but directly inside Documents. Usually, it is inside a project not user Home.

hm. No idea what packrat is. I just put everything in documents. Would organizing my stuff and using packtrat solve the ERROR?

For some reason your packages are installing into a packrat librairie and not your user library. Outside of a project , I don’t think this is a good idea.

When you open a clean R session in rstudio, what is the result of ˋ.Libpaths()` ?

Your are using packrat without knowing , not the best thing I think. We’ll see how to undo that.

And you definitely use Rstudio project for your work!
Look at this for a start

1 Like

Thanks a lot, much appreciated. I have reading to do :slight_smile:
cheers

Hello! Following the book chapter 8, I have created projects and organized my files. Much better.

When I open Rstudio, there is a packrat ERROR


R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'packrat/init.R': No such file or directory

Here is the result of ˋ.Libpaths()`

> Libpaths()
Error in Libpaths() : could not find function "Libpaths"


Same Libpath error in Documents.

I understand I need to specify the library location when I install it. Ill try it.

Do you have a .Rprofile in you project or home directory ?
Packrat create one that tries to source a packrat/init.R that should not exist anymore (hence the error)
Can you check if it exists and what is inside ?

Also, the call is .libPaths(). Sorry I had the wrong upper letter.

> .libPaths()
[1] "C:/Users/Agathe/Documents/R/win-library/3.5" "C:/Program Files/R/R-3.5.1/library"

yes. There is a file ".Rprofile" in Documents. Where everything was before I made Projects. I dont know how to open it?

Thats it:

#### -- Packrat Autoloader (version 0.5.0) -- ####
source("packrat/init.R")
#### -- End Packrat Autoloader -- ####

What should I do with packrat -uninstall, or learn what it is and use it? I get this ERROR message when I start R:

Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'packrat/init.R': No such file or directory

And, does it have something to do with my first problem installing ggbiplot?

Thanks a lot

ok so now your .libPaths() points to the standard user library. If you can't open the project, you can delete the lines

#### -- Packrat Autoloader (version 0.5.0) -- ####
source("packrat/init.R")
#### -- End Packrat Autoloader -- ####

so that does not try to load the init file.

You have to retry to install your :package: in a clean session. Have you tried already ?

Hi,

Thanks for your help -Much appreciated!
I really want to learn this, and every little thing is an obstacle. :frowning:

  1. I open my project in a new session and the packrat error appears. I dont know where are the lines that you recommend to delete?

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'packrat/init.R': No such file or directory
  1. New problem: I cannot load data. Is it linked to the "error in file" above? I get this error:
> GLOPIS <- read.delim("~/GLOPIS_GICC05-Frontier2015.TXT")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  1. Trying to solve my initial problem to install ggbiplot, I get the same error. I re-installed the packages in a new session, and get the same error (scroll down the end):
> install.packages("devtools")
Installing package into ‘C:/Users/Agathe/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘ps’, ‘backports’, ‘ini’, ‘processx’, ‘curl’, ‘mime’, ‘openssl’, ‘desc’, ‘prettyunits’, ‘rprojroot’, ‘xopen’, ‘clipr’, ‘clisymbols’, ‘fs’, ‘gh’, ‘whisker’, ‘callr’, ‘git2r’, ‘httr’, ‘jsonlite’, ‘memoise’, ‘pkgbuild’, ‘pkgload’, ‘rcmdcheck’, ‘remotes’, ‘rstudioapi’, ‘sessioninfo’, ‘usethis’


  There is a binary version available but the source version is later:
          binary source needs_compilation
rcmdcheck  1.3.1  1.3.2             FALSE

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/ps_1.3.0.zip'
Content type 'application/zip' length 306296 bytes (299 KB)
downloaded 299 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/backports_1.1.3.zip'
Content type 'application/zip' length 65892 bytes (64 KB)
downloaded 64 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/ini_0.3.1.zip'
Content type 'application/zip' length 15500 bytes (15 KB)
downloaded 15 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/processx_3.2.1.zip'
Content type 'application/zip' length 306244 bytes (299 KB)
downloaded 299 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/curl_3.3.zip'
Content type 'application/zip' length 2995621 bytes (2.9 MB)
downloaded 2.9 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/mime_0.6.zip'
Content type 'application/zip' length 47809 bytes (46 KB)
downloaded 46 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/openssl_1.1.zip'
Content type 'application/zip' length 3937463 bytes (3.8 MB)
downloaded 3.8 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/desc_1.2.0.zip'
Content type 'application/zip' length 283924 bytes (277 KB)
downloaded 277 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/prettyunits_1.0.2.zip'
Content type 'application/zip' length 33184 bytes (32 KB)
downloaded 32 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rprojroot_1.3-2.zip'
Content type 'application/zip' length 83810 bytes (81 KB)
downloaded 81 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/xopen_1.0.0.zip'
Content type 'application/zip' length 24461 bytes (23 KB)
downloaded 23 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/clipr_0.5.0.zip'
Content type 'application/zip' length 40709 bytes (39 KB)
downloaded 39 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/clisymbols_1.2.0.zip'
Content type 'application/zip' length 20895 bytes (20 KB)
downloaded 20 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/fs_1.2.6.zip'
Content type 'application/zip' length 956275 bytes (933 KB)
downloaded 933 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/gh_1.0.1.zip'
Content type 'application/zip' length 49043 bytes (47 KB)
downloaded 47 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/whisker_0.3-2.zip'
Content type 'application/zip' length 80955 bytes (79 KB)
downloaded 79 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/callr_3.1.1.zip'
Content type 'application/zip' length 244962 bytes (239 KB)
downloaded 239 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/git2r_0.24.0.zip'
Content type 'application/zip' length 2873845 bytes (2.7 MB)
downloaded 2.7 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/httr_1.4.0.zip'
Content type 'application/zip' length 495960 bytes (484 KB)
downloaded 484 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/jsonlite_1.6.zip'
Content type 'application/zip' length 1160693 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/memoise_1.1.0.zip'
Content type 'application/zip' length 36431 bytes (35 KB)
downloaded 35 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/pkgbuild_1.0.2.zip'
Content type 'application/zip' length 128276 bytes (125 KB)
downloaded 125 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/pkgload_1.0.2.zip'
Content type 'application/zip' length 154962 bytes (151 KB)
downloaded 151 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/remotes_2.0.2.zip'
Content type 'application/zip' length 273234 bytes (266 KB)
downloaded 266 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rstudioapi_0.9.0.zip'
Content type 'application/zip' length 204226 bytes (199 KB)
downloaded 199 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/sessioninfo_1.1.1.zip'
Content type 'application/zip' length 46417 bytes (45 KB)
downloaded 45 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/usethis_1.4.0.zip'
Content type 'application/zip' length 521099 bytes (508 KB)
downloaded 508 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/devtools_2.0.1.zip'
Content type 'application/zip' length 384843 bytes (375 KB)
downloaded 375 KB

package ‘ps’ successfully unpacked and MD5 sums checked
package ‘backports’ successfully unpacked and MD5 sums checked
package ‘ini’ successfully unpacked and MD5 sums checked
package ‘processx’ successfully unpacked and MD5 sums checked
package ‘curl’ successfully unpacked and MD5 sums checked
package ‘mime’ successfully unpacked and MD5 sums checked
package ‘openssl’ successfully unpacked and MD5 sums checked
package ‘desc’ successfully unpacked and MD5 sums checked
package ‘prettyunits’ successfully unpacked and MD5 sums checked
package ‘rprojroot’ successfully unpacked and MD5 sums checked
package ‘xopen’ successfully unpacked and MD5 sums checked
package ‘clipr’ successfully unpacked and MD5 sums checked
package ‘clisymbols’ successfully unpacked and MD5 sums checked
package ‘fs’ successfully unpacked and MD5 sums checked
package ‘gh’ successfully unpacked and MD5 sums checked
package ‘whisker’ successfully unpacked and MD5 sums checked
package ‘callr’ successfully unpacked and MD5 sums checked
package ‘git2r’ successfully unpacked and MD5 sums checked
package ‘httr’ successfully unpacked and MD5 sums checked
package ‘jsonlite’ successfully unpacked and MD5 sums checked
package ‘memoise’ successfully unpacked and MD5 sums checked
package ‘pkgbuild’ successfully unpacked and MD5 sums checked
package ‘pkgload’ successfully unpacked and MD5 sums checked
package ‘remotes’ successfully unpacked and MD5 sums checked
package ‘rstudioapi’ successfully unpacked and MD5 sums checked
package ‘sessioninfo’ successfully unpacked and MD5 sums checked
package ‘usethis’ successfully unpacked and MD5 sums checked
package ‘devtools’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\Agathe\AppData\Local\Temp\RtmpumvyZO\downloaded_packages
installing the source package ‘rcmdcheck’

trying URL 'https://cran.rstudio.com/src/contrib/rcmdcheck_1.3.2.tar.gz'
Content type 'application/x-gzip' length 1408582 bytes (1.3 MB)
downloaded 1.3 MB

Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
Calls: source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'packrat/init.R': No such file or directory
Execution halted
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘rcmdcheck’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\Agathe\AppData\Local\Temp\RtmpumvyZO\downloaded_packages’
> 

How to fix that new error?

The file is definitely there and R sees it. For example:

> list.files()
[1] "LA-N1_ITRAX.txt" "PCA.R"           "PCA.Rproj"       "stats.R"        
> #load data
> ITRAX <- read.delim("~/LA-N1_ITRAX.txt")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :

Where is your file relatively to your project ? From the result of list.files can you try

ITRAX <- read.delim("LA-N1_ITRAX.txt")

?

Do you still have a Rprofile file somewhere ?
Can you see by calling usethis::edit_r_profile() and usethis::edit_r_profile("project") ?

Do you have something written in those file ?

Do you have one is ~/.Rprofile too ?

There is definitely something off with packrat initialization somewhere in your configuration files.

Thanks! It works without ~/. I can load data.

RProfile is still in the folder Documents.

From one of my project, I tried what you suggested:

> usethis::edit_r_profile("project")
✔ Setting active project to 'C:/Users/Agathe/Documents/DTW'
● Modify '.Rprofile'
● Restart R for changes to take effect

There is nothing in this Rprofile. I think it just created a new RProfile file in this project.

Now this:

> usethis::edit_r_profile() 
● Modify 'C:/Users/Agathe/Documents/.Rprofile'
● Restart R for changes to take effect

I can see the RProfile code:

#### -- Packrat Autoloader (version 0.5.0) -- ####
source("packrat/init.R")
#### -- End Packrat Autoloader -- ####

I delete it and restart R.

Problem solved. No more packrat error. Thanks :smiley:

Good news! ggbiplot works like a charm.
Problem solved.

Merci cderv, you rock!

Cheers,
Agathe