Installing ggbiplot from github - r

I'm trying to install development version of ggbiplotfrom Github. During installation I'm getting the following error message:
library(devtools)
install_github("ggbiplot", "vqv")
Installing github repo(s) ggbiplot/master from vqv
Installing ggbiplot.zip from https://github.com/vqv/ggbiplot/zipball
Installing ggbiplot
* checking for file 'C:\Users\Muhammad Yaseen\AppData\Local\Temp\Rtmpsx4n5u\vqv-ggbiplot-2623d7c/DESCRIPTION' ... OK
* preparing 'ggbiplot':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'ggbiplot_0.5.tar.gz'
cygwin warning:
MS-DOS style path detected: C:/Users/MUHAMM~1/AppData/Local/Temp/Rtmpsx4n5u/ggbiplot_0.5.tar.gz
Preferred POSIX equivalent is: /cygdrive/c/Users/MUHAMM~1/AppData/Local/Temp/Rtmpsx4n5u/ggbiplot_0.5.tar.gz
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Warning: invalid package 'Yaseen/R/win-library/2.14'
Error: ERROR: cannot cd to directory 'C:/Users/Muhammad'
Error: Command failed (1)
In addition: Warning message:
running command '"C:/PROGRA~1/R/R-214~1.2/bin/i386/R" CMD INSTALL C:\Users\MUHAMM~1\AppData\Local\Temp\Rtmpsx4n5u/ggbiplot_0.5.tar.gz --library=C:/Users/Muhammad Yaseen/R/win-library/2.14' had status 1
Any idea to figure out this problem. Thanks in advance for your help and time.
Edit
After downloading from Github, also tried
install.packages("vqv-ggbiplot-2623d7c.tar.gz", repos=NULL, type="source")
which produced this error message
Installing package(s) into ‘C:/Users/Muhammad Yaseen/R/win-library/2.14’
(as ‘lib’ is unspecified)
Error in untar2(tarfile, files, list, exdir) : unsupported entry type 'g'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-214~1.2/bin/i386/R CMD INSTALL -l "C:/Users/Muhammad Yaseen/R/win-library/2.14" "vqv-ggbiplot-2623d7c.tar.gz"' had status 1
2: In install.packages("vqv-ggbiplot-2623d7c.tar.gz", repos = NULL, :
installation of package ‘vqv-ggbiplot-2623d7c.tar.gz’ had non-zero exit status

It's because your Rlib path has a space in it: C:/Users/Muhammad Yasseen/R/win-library/2.14.
See how in the first error log the warning message was
running command '"C:/PROGRA~1/R/R-214~1.2/bin/i386/R" CMD INSTALL
C:\Users\MUHAMM~1\AppData\Local\Temp\Rtmpsx4n5u/ggbiplot_0.5.tar.gz
--library=C:/Users/Muhammad Yaseen/R/win-library/2.14'
had status 1
In particular, the --library=C:/Users/Muhammad Yaseen/R/win-library/2.14.
This should be --library="C:/Users/Muhammad Yaseen/R/win-library/2.14" to deal with the space.
Using install.packages takes care of the quotes for you - see how your second warning message (when you used install.packages) was
running command 'C:/PROGRA~1/R/R-214~1.2/bin/i386/R CMD INSTALL
-l "C:/Users/Muhammad Yaseen/R/win-library/2.14"
"vqv-ggbiplot-2623d7c.tar.gz"' had status 1
The -l "C:/Users/Muhammad Yasseen/R/win-library/2.14" has quote marks around it, so you don't get the same error.
I had a quick look at the install-github sources, and it constructs the R CMD INSTALL command via:
paste("CMD INSTALL ", built_path, " --library=", .libPaths()[1], sep="")
See how it doesn't surround .libPaths()[1] by double quotes in case of spaces? I'd guess that's your problem.
As to a fix - there seems to be an error using install.packages() on a tar file generated by git (as reported here). So, you can either:
change your R library location to somewhere without spaces
unzip the .tar.gz file (I don't know what software does this on Windows) and install from the extracted directories rather than the .tar.gz.

You can't unzip the .tar.gz because it cleans up that file quicker than you can grab it (I've watched it appear and get deleted again). Correct me if I'm wrong, but I also can't get devtools from github for teh same reason :S

Related

syntax error near unexpected token - R package Install

I am trying to install an R package along with its dependencies. But it is throwing error.
$ install.packages(rvest_0.3.5.tar.gz, dependencies=True)
-bash: syntax error near unexpected token `rvest_0.3.5.tar.gz,'
I am new to R please help me how can I download this along with it dependencies.
Before this, I tried following
$ R CMD INSTALL rvest_0.3.5.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’
ERROR: dependencies ‘httr’, ‘magrittr’, ‘selectr’ are not available for package ‘rvest’
But it failed with dependent packages are missing error. And obviously it is cumbersome to install the dependent packages manually. Hence I tried package.install
You need to run it with quotes and capital TRUE:
install.packages("rvest_0.3.5.tar.gz", dependencies = TRUE)
Note this will only work if you have unix-like system and the file is located in your current working directory (check with running getwd() from your R session). Otherwise you need to provide full path to the file (like "~/somefolder/mydata/rvest_0.3.5.tar.gz").
If you run Windows, then you need .zip file instead of .tar.gz.
If you are connected to internet, just run:
install.packages("rvest")

In R (and when installing ROracle package), how do I set OCI_LIB64?

In R (and when installing ROracle package), how do I set OCI_LIB64? I've downloaded Oracle Instant Client and have pointed the wd and the OCI_LIB64 to that. I have Windows 10 Enterprise. It's RStudio version 1.1.463 and R version 3.4.3.
I tried the following:
setwd('C:\\Users\\sriley03\\Documents\\') # set to path of download (remember to escape slashes ie: c:\\users\\etc..)
set OCI_LIB64=C:\Users\sriley03\Documents\instantclient_19_3
install.packages('ROracle_1.3-1.tar.gz', repos = NULL)
but I get the following output and errors:
> setwd('C:\\Users\\sriley03\\Documents\\') # set to path of download (remember to escape slashes ie: c:\\users\\etc..)
The working directory was changed to C:/Users/sriley03/Documents/ inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.Error: unexpected symbol in "set OCI_LIB64"
> setwd('C:\\Users\\sriley03\\Documents\\instantclient_19_3') # set to path of download (remember to escape slashes ie: c:\\users\\etc..)
The working directory was changed to C:/Users/sriley03/Documents/instantclient_19_3 inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.> set OCI_LIB64=C:\Users\sriley03\Documents\instantclient_19_3
Error: unexpected symbol in "set OCI_LIB64"
> install.packages('ROracle_1.3-1.tar.gz', repos = NULL)
Warning: invalid package 'ROracle_1.3-1.tar.gz'
Error: ERROR: no packages specified
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.4.3\library" "ROracle_1.3-1.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘ROracle_1.3-1.tar.gz’ had non-zero exit status
What can I do so that I can set OCI_LIB64 properly so that I can install ROracle?
Thanks!
UPDATE (8_28_19):
I've set the OCI_LIB64 and the OCI_INC to the correct paths
Sys.setenv(OCI_LIB64="C:\\Users\\sriley03\\Documents\\oreclient_install_dir\\instantclient_19_3")
Sys.setenv(OCI_INC="C:\\Users\\sriley03\\Documents\\oreclient_install_dir\\instantclient_19_3")
But now I get the following response (even though all the required headers are in that file):
* installing *source* package 'ROracle' ...
** package 'ROracle' successfully unpacked and MD5 sums checked
Oracle Client Shared Library 64-bit - 19.3.0.0.0 Operating in Instant Client mode.
found Oracle Client C:\Users\sriley03\Documents\oreclient_install_dir\instantclient_19_3
found Oracle Client include C:\Users\sriley03\Documents\oreclient_install_dir\instantclient_19_3
ERROR: cannot find Oracle Client include headers in C:\Users\sriley03\Documents\oreclient_install_dir\instantclient_19_3.
Please set OCI_INC to correct location.
Warning: running command 'sh ./configure.win' had status 1
ERROR: configuration failed for package 'ROracle'
* removing 'C:/Program Files/R/R-3.4.3/library/ROracle'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.4.3\library" C:\Users\sriley03\AppData\Local\Temp\RtmpWUfabz/downloaded_packages/ROracle_1.3-1.tar.gz' had status 1
Try to download the SDK Package from Oracle and unzip it in your instant client folder.
set the environment variable OCI_INC to the 'include' folder located in your instant client folder: ..."instantclient_xx_x\sdk\include"
Then, reinstall the packages.
If you still get a failure error, try to copy all files from sdk\include folder to your R include folder, then try again

Installing R package ERROR: installing binary package failed

Complete newbie here, so there is probably something glaringly bad here. I created a Project following Hadley Wickham's book on R packages, and now I am trying add it to github for remote install (repository for reference).
Running devtools::install_github("alutterb/abcmlr") generated the following output:
Downloading GitHub repo alutterb/abcmlr#master
√ checking for file 'C:\Users\amlut\AppData\Local\Temp\RtmpMpn5uJ\remotes7146c405dd7\alutterb-abcmlr-918bf05/DESCRIPTION' ...
- preparing 'abcmlr':
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'abcmlr_0.1.0.tar.gz'
Installing package into ‘C:/Users/amlut/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *binary* package 'abcmlr' ...
cp: unknown option -- )
Try '/Rtools/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Users/amlut/Documents/R/win-library/3.5/abcmlr'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘C:/Users/amlut/AppData/Local/Temp/RtmpMpn5uJ/file71463953e7b/abcmlr_0.1.0.tar.gz’ had non-zero exit status
In my repository, I have a Linux executable that is to be used with wsl as well as an .exe file that is called in my R code. These may be the culprits, but I am not entirely sure. The error states that it failed to install the binary package, but install_github() takes a source package, so I am not sure what is going on. Any help is appreciated.
Thank you.
EDIT: This problem is solved. It was because of a line in my DESCRIPTION file that had to do with Built.
Check your %PATH% and type: where cp.
Another cp (like one from the Git for Windows distribution) might overshadow the RTools cp, which might explain the error message.
As commented by the OP hkj447, the error was trigger by a line in the DESCRIPTION file:
Built: R 3.5.3; ; 2019-06-14 21:17:43 UTC; windows
As seen in this thread:
You have a field called 'Built:' in your package's DESCRIPTION file;
R normally tries to inject that field itself when it builds your package from sources.
I deleted "Built"'s line in DESCRIPTION and then installed again.
This time, no error appeared.

Error in installing car package in R

While installing "car" package in Rstudio in Ubuntu, I faced an error saying that dependencies "nloptr","lme4" and one more, are not installed.
So I started installing "nloptr" but I faced this error-
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-
2.4.2.tar.gz", :
cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Execution halted
/bin/tar: This does not look like a tar archive
gzip: stdin: unexpected end of file
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
'/bin/tar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to
/tmp/RtmpSeLv7g/R.INSTALL18a67910d582/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory
System hangs after last line and when I restart after some time, "nloptr" is not installed and hence I am unable to install "car" package.
Please help me. Thanks in advance.
I was encountering the same problem under R (pure R 3.2.3 on Linux Debian). I was first blocked by another issue during the same installation : the installation process failed to lock directory ~/.../R/x86_64.../3.2 and suggested to remove ~/.../R/x86_64.../3.2/00LOCK-nloptr . I did it, restart the car package installation, and then it blocked at the same point: it needs nlopt.h.
So, I installed libnlopt-dev (sudo apt-get install libnlopt-dev) and re-restart the car installation ... and then it worked.
Ok, this is under linux, but perhaps should you try to focus on installing something about NLOPT under windows.
Good luck.

Cannot install my created packages

I've been writing a lot of code for my personal use and finally reached a point where I realised I should really be including this all in a package which I can load in instead of copy and pasting it in each time.
I followed the following tutorial for the creation of a basic package.
https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
As far as I can tell everything went well with the actual creation element. Here are screenshots of the result:
The cats folder:
The /cats/R folder
The /cats/man folder
The problem comes when I want to run the line:
install("cats")
When I try to do that I get the following error:
Installing cats
"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "/Documents/cats" --library="C:/Users/Aodhán/Documents/R/win-library/3.3" --install-tests
* installing *source* package 'cats' ...
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats/DESCRIPTION': No such file or directory
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
* removing 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats'
Error: Command failed (1)
This error happens for my own package, but it also happens if I run the command:
devtools::install_github("klutometis/roxygen")
Any advice would be appreciated.
EDIT: Could it be that my username contains the character á in it?
EDIT 2:The DESCRIPTION file is:
Package: cats
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors#R: person("First", "Last", email = "first.last#example.com",
role = c("aut", "cre"))
Maintainer: Aodhán O'Leary
Author: Aodhán O'Leary [aut, cre]
Description: What the package does (one paragraph).
Depends: R (>= 3.3.1)
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Sys.getenv("R_HOME") returns "C:/PROGRA~1/R/R-33~1.1"
Sys.getenv("R_LIBS_USER") returns "C:\Users\Aodhán\Documents/R/win-library/3.3"
Sys.getenv("R_HOME") returns "C:\Users\Aodhán\Documents"
devtools::build("cats") creates "cats_0.0.0.9000.tar.gz"
install.packages("../cats_version.tar.gz") returns the same error as above
Note: This is on a Win10 machine, using R 3.3.1, which I apologise for not mentioning up top. I was quite tired when writing the post yesterday.
Edit 3: Here's the result of using the following commands: R CMD build cats followed by R CMD check cats
00check:
using log directory 'C:/Users/Aodhán/Documents/cats.Rcheck'
using R version 3.3.1 (2016-06-21)
using platform: x86_64-w64-mingw32 (64-bit)
using session charset: ISO8859-1
checking for file 'cats/DESCRIPTION' ... OK
this is package 'cats' version '0.0.0.9000'
package encoding: UTF-8
checking package namespace information ... OK
checking package dependencies ... OK
checking if this is a source package ... OK
checking if there is a namespace ... OK
checking for .dll and .exe files ... OK
checking for hidden files and directories ... NOTE Found the following hidden files and directories: .gitignore These were most
likely included in error. See section 'Package structure' in the
'Writing R Extensions' manual.
checking for portable file names ... OK
checking whether package 'cats' can be installed ... ERROR Installation failed. See
'C:/Users/Aodhán/Documents/cats.Rcheck/00install.out' for details.
DONE
Status: 1 ERROR, 1 NOTE
00install.out
installing source package 'cats' ...
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Aodhan/Documents/cats.Rcheck/cats/DESCRIPTION':
No such file or directory
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
removing 'C:/Users/Aodhán/Documents/cats.Rcheck/cats'
The problem was the special character in my name, á. When I put it in the C:\ directory and ran R CMD build cats and R CMD check cats it passed that error (though there was an error later on with the pdf - I'll see if I can resolve that myself).
I'll try and post this as a bug. Moderately annoying. Should have thought of that test earlier.
I've run into this problem recently (R version 3.5.2) on two different computers. I don't have the full, exact error message right now, but it contained the following two snippets:
Error in writeLines(paste0(c(out[is_not_empty]), eor), file, useBytes = useBytes) :
(converted from warning) invalid char string in output conversion
and
ERROR: installing package DESCRIPTION failed for package
The problem, I believe, was the existence of special characters in my .Rprofile file. I'd been meaning to get rid of that file anyway (for the sake of reproducibility), and doing so fixed the problem.
To do this in R, the code below will (1) copy your .Rprofile and save it as .Rprofile-old (in case you want to use/restore it later on) and then (2) delete your .Rprofile.
## copy backup of .Rprofile
file.copy("~/.Rprofile", "~/.Rprofile-old")
## delete .Rprofile
unlink("~/.Rprofile")
Once you've run the above code, restart R and the problem will [hopefully] be fixed!
Installing source package..
It is important to specify repo and type
Convert package into package_name.tar.gz
Get into project environment by double clicking the .Rproj file in
your project and click on build -> Build Source Package to build tar.gz file
install.packages("full_path/package_name.tar.gz", repo = NULL, type =
"source")

Resources