How can I use R function download.file? - r

I've tried to run this command:
url <- 'http://www.rob-mcculloch.org/chm/nonlinvarsel_0.0.1.9001.tar.gz'
download.file(url, destfile = 'temp')
install.packages('temp', repos = NULL, type='source')
But at first, when I ran download.file, that returned me:
Warning messages: 1: In download.file(url, destfile = "temp") : URL http://www.rob-mcculloch.org/chm/nonlinvarsel_0.0.1.9001.tar.gz: cannot open destfile 'temp', reason 'Is a directory' 2: In download.file(url, destfile = "temp") : download had nonzero exit status
So I tried to run install.packages and that returned me:
Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) Warning: invalid package ‘temp’ Error: ERROR: no packages specified Warning message: In install.packages("temp", repos = NULL, type = "source") : installation of package ‘temp’ had non-zero exit status

You don't have to do it from inside R (though that is doable, just look more close at options and see below). I actually like the shell for this:
/tmp> wget http://www.rob-mcculloch.org/chm/nonlinvarsel_0.0.1.9001.tar.gz
--2022-04-11 03:03:59-- http://www.rob-mcculloch.org/chm/nonlinvarsel_0.0.1.9001.tar.gz
Resolving www.rob-mcculloch.org (www.rob-mcculloch.org)... 162.241.219.65
Connecting to www.rob-mcculloch.org (www.rob-mcculloch.org)|162.241.219.65|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20001 (20K) [application/x-gzip]
Saving to: ‘nonlinvarsel_0.0.1.9001.tar.gz’
nonlinvarsel_0.0.1.9001.tar.gz 100%[=====================================================================================================================>] 19.53K --.-KB/s in 0.03s
2022-04-11 03:03:59 (634 KB/s) - ‘nonlinvarsel_0.0.1.9001.tar.gz’ saved [20001/20001]
/tmp> R CMD INSTALL nonlinvarsel_0.0.1.9001.tar.gz
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘nonlinvarsel’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (nonlinvarsel)
/tmp>
Or equally within R (where I also switch to /tmp) first:
> setwd("/tmp")
> download.file("http://www.rob-mcculloch.org/chm/nonlinvarsel_0.0.1.9001.tar.gz", "nonlinvarsel_0.0.1.9001.tar.gz")
trying URL 'http://www.rob-mcculloch.org/chm/nonlinvarsel_0.0.1.9001.tar.gz'
Content type 'application/x-gzip' length 20001 bytes (19 KB)
==================================================
downloaded 19 KB
> install.packages("nonlinvarsel_0.0.1.9001.tar.gz", repos = NULL)
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘nonlinvarsel’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (nonlinvarsel)
>

Related

Error message when installing package expss

I'm trying to download the package 'expss' in R, but I get an error message that I don't know how to solve.
This is what R tells me after trying to install 'expss':
installing the source package ‘expss’
trying URL 'https://cran.rstudio.com/src/contrib/expss_0.11.2.tar.gz'
Content type 'application/x-gzip' length 5002788 bytes (4.8 MB)
==================================================
downloaded 4.8 MB
* installing *source* package ‘expss’ ...
** package ‘expss’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘expss’:
object 'mtfrm' not found whilst loading namespace 'expss'
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/expss’
Warning in install.packages :
installation of package ‘expss’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/86/04fdfqg9769g8w7ss25qnw600000gn/T/RtmpELbScA/downloaded_packages’
Any help appreciated!

Download R Package via Github

I've been attempting to install the rethinking package for R. I've downloaded the prerequisites, including rstan, but am still getting the same error message. My code is as follows:
library(devtools)
install_github("rmcelreath/rethinking")
I keep getting this output:
Downloading GitHub repo rmcelreath/rethinking#master
Skipping 1 packages ahead of CRAN: StanHeaders
√ checking for file 'C:\Users\noahj\AppData\Local\Temp\RtmpK0JHwE\remotes2a60431d781f\rmcelreath-rethinking-f393f30/DESCRIPTION' ...
- preparing 'rethinking': (1.6s)
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts (725ms)
- checking for empty or unneeded directories
- looking to see if a 'data/datalist' file should be added
- building 'rethinking_2.00.tar.gz' (699ms)
Installing package into ‘C:/Users/noahj/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package 'rethinking' ...
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
Error: (converted from warning) package 'rstan' was built under R version 3.6.3
Execution halted
ERROR: lazy loading failed for package 'rethinking'
* removing 'C:/Users/noahj/Documents/R/win-library/3.6/rethinking'
Error: Failed to install 'rethinking' from GitHub:
(converted from warning) installation of package ‘C:/Users/noahj/AppData/Local/Temp/RtmpK0JHwE/file2a605bda3304/rethinking_2.00.tar.gz’ had non-zero exit status
Thank you to anyone with any insights and help!

cannot authenticate r shinyapps account with rsconnect

Trying to install reconnect and authenticate it with R-shiny. However, it seems unable to find the function file size.
Here is the installation:
> install.packages("rsconnect", type = "source", dependencies = TRUE, repos = "http://cran.rstudio.com/")
Installing package into ‘/Users/~/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/rsconnect_0.8.8.tar.gz'
Content type 'application/x-gzip' length 245177 bytes (239 Kb)
opened URL
==================================================
downloaded 239 Kb
* installing *source* package ‘rsconnect’ ...
** package ‘rsconnect’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (rsconnect)
The downloaded source packages are in
/private/VAb/downloaded_packages
Here is the error when I try to register my account.
rsconnect::setAccountInfo(name='me',
+ token='token',
+ secret='pass')
Error in inferCertificateContents(system.file("cert/shinyapps.io.pem", :
could not find function "file.size"

Trouble installing glmmadmb in R

I am having trouble installing glmmADMB package and hoping to get some help here. I've talked to people I know who uses R but we couldn't figure this out.
Looks like the error is about a symbol in the directory. However, the ' is included as a default naming convention in Windows and I can't seem to change the folder name. I name my computer Vanessa and it automatically give the user folder name "Vanessa's PC". [It might not due to this error, since I have ran some other codes that included this symbol in the command.] Any suggestions or thoughts would be greatly appreciated.
This is the log I got:
install.packages("glmmADMB",
+ repos=c("http://glmmadmb.r-forge.r-project.org/repos",
+ getOption("repos")),
+ type="source")
Installing package into ‘C:/Users/Vanessa's PC/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'http://glmmadmb.r-forge.r-project.org/repos/src/contrib/glmmADMB_0.8.3.3.tar.gz'
Content type 'application/x-gzip' length 9391177 bytes (9.0 MB)
downloaded 9.0 MB
installing source package 'glmmADMB' ...
** R
** data
* moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Warning: package 'MASS' was built under R version 3.4.4
** help
* installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* arch - i386
Error: unexpected symbol in "tools:::.test_load_package('glmmADMB', 'C:/Users/Vanessa's"
Execution halted
* arch - x64
Error: unexpected symbol in "tools:::.test_load_package('glmmADMB', 'C:/Users/Vanessa's"
Execution halted
ERROR: loading failed for 'i386', 'x64'
removing 'C:/Users/Vanessa's PC/Documents/R/win-library/3.4/glmmADMB'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "C:\Users\Vanessa's PC\Documents\R\win-library\3.4" C:\Users\VANESSA'S~1\AppData\Local\Temp\Rtmp2piXfe/downloaded_packages/glmmADMB_0.8.3.3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘glmmADMB’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\Vanessa's PC\AppData\Local\Temp\Rtmp2piXfe\downloaded_packages’
Try installing the devtools package first and then installing glmmADMB directly from the development version on GitHub:
> library(devtools)
> devtools::install_github("bbolker/glmmadmb")
Downloading GitHub repo bbolker/glmmadmb#master
from URL https://api.github.com/repos/bbolker/glmmadmb/zipball/master
Installing glmmADMB
Installing 1 package: R2admb
Installing package into ‘C:/Users/User/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.4/R2admb_0.7.16.zip'
Content type 'application/zip' length 505317 bytes (493 KB)
downloaded 493 KB
package ‘R2admb’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\User\AppData\Local\Temp\Rtmp4WWJZp\downloaded_packages
"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" --no-site-file --no-environ
--no-save -- no-restore --quiet CMD INSTALL \
"C:/Users/User/AppData/Local/Temp/Rtmp4WWJZp/devtools28d0200a7e9b/bbolker-
glmmadmb-ac75f73" \
--library="C:/Users/User/Documents/R/win-library/3.4" --install-tests
* installing *source* package 'glmmADMB' ...
....
> library(glmmADMB)
Loading required package: MASS
Attaching package: ‘glmmADMB’
The following object is masked from ‘package:MASS’:
stepAIC
The following object is masked from ‘package:stats’:
step
This works:
install.packages("R2admb")
install.packages("glmmADMB",
repos=c("http://glmmadmb.r-forge.r-project.org/repos",
getOption("repos")),
type="source")
library(glmmADMB)

Hive library installation in R : error

I want to connect R with Hive using hive package, however I am unable to
install hive library in R.. Please help.
I am using R Server which is in the same machine where my hadoop (hartoworks 2.1 ) cluster cluster is there.
Below is the error message.
Sys.setenv("hive_home" ="/usr/lib/hive")
Sys.setenv("hadoop_home"="/usr/lib/hadoop")
install.packages("hive", dependencies=T)
Installing package into ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/hive_0.2-0.tar.gz'
Content type 'application/x-gzip' length 32886 bytes (32 KB)
opened URL
==================================================
downloaded 32 KB
* installing *source* package ‘hive’ ...
** package ‘hive’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
converting help for package ‘hive’
finding HTML links ... done
DFS html
configuration html
hive html
hive_stream html
** building package indices
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'hive', details:
call: .jnew("org/apache/hadoop/fs/Path", file.path(hadoop_home(henv),
error: java.lang.ClassNotFoundException
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1/hive’
* restoring previous ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1/hive’
Warning in install.packages :
installation of package ‘hive’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpDsXs7i/downloaded_packages’

Resources