Installing C libraries in R? - r

I am working with the R programming language.
I would like to download this library from github : https://github.com/Datactuariat/Rpostal
I entered the following code in R:
# install from github
devtools::install_github("datactuariat/Rpostal")
library(Rpostal)
After this, I tried one of the demo commands:
# Postal Expand
postal_expand("Quatre vignt douze Ave des Champs-Élysées")
But I get the following error:
Loading required package: jsonlite
Error in system(req, intern = TRUE) :
'~/libpostal/src/libpostal' not found
I have a feeling that this is because I did not install the "libpostal C libraries" - but no instructions are provided for doing this in a Windows Environment (I am using Windows).
Can someone please show me what I am doing wrong and how I can fix this problem?
Thanks!
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] jsonlite_1.8.0 Rpostal_0.0.0.9000
loaded via a namespace (and not attached):
[1] compiler_4.1.3 prettyunits_1.1.1 remotes_2.4.2 tools_4.1.3 testthat_3.1.4 digest_0.6.29
[7] pkgbuild_1.3.1 pkgload_1.2.4 evaluate_0.15 memoise_2.0.1 lifecycle_1.0.1 rlang_1.0.2
[13] cli_3.3.0 rstudioapi_0.13 curl_4.3.2 yaml_2.3.5 xfun_0.30 fastmap_1.1.0
[19] withr_2.5.0 knitr_1.39 desc_1.4.1 fs_1.5.2 devtools_2.4.3 rprojroot_2.0.3
[25] glue_1.6.2 R6_2.5.1 processx_3.5.3 rmarkdown_2.14 sessioninfo_1.2.2 callr_3.7.0
[31] purrr_0.3.4 magrittr_2.0.2 ps_1.6.0 ellipsis_0.3.2 htmltools_0.5.2 usethis_2.1.6
[37] tinytex_0.40 cachem_1.0.6 crayon_1.5.1 brio_1.1.3

Related

Installing additional packages through Rprofile

I want to install additional packages besides the default ones every time I restart my R Session.
I have tried this: options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os)))
install.packages(c(
'shinydashboard',
'shinyWidgets',
'rlist',
'sortable',
'tidyverse',
'XML',
'DescTools',
'plotly',
'leaflet',
'tidyquant',
'umap'
))
And this options(defaultPackages = c(getOption("defaultPackages"), "tidyquant", ...)) neither of which works. If all I want to do is to install the tidyquant package upon the R Session restart, how do I get it to work inside the Rprofile file?
I would definitely take #dirk-eddelbuettel's advice on this (XY problem), but it is possible if you add this to your .Rprofile:
.First <- function(){
utils::install.packages("tidyquant", repos="https://cran.csiro.au/")
library(tidyquant)
}
(This command is run before any packages are loaded so you need to specify the install.packages function comes from utils).
Not sure if this applies to windows; my system info:
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.4
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] graphics grDevices utils datasets stats methods
[7] base
other attached packages:
[1] tidyquant_1.0.4 quantmod_0.4.20
[3] TTR_0.24.3 PerformanceAnalytics_2.0.4
[5] xts_0.12.1 zoo_1.8-10
[7] lubridate_1.8.0
loaded via a namespace (and not attached):
[1] magrittr_2.0.3 tidyselect_1.1.2 munsell_0.5.0
[4] colorspace_2.0-3 lattice_0.20-45 R6_2.5.1
[7] rlang_1.0.2 quadprog_1.5-8 fansi_1.0.3
[10] dplyr_1.0.9 httr_1.4.3 tcltk_4.1.3
[13] tools_4.1.3 grid_4.1.3 gtable_0.3.0
[16] utf8_1.2.2 DBI_1.1.2 cli_3.3.0
[19] ellipsis_0.3.2 assertthat_0.2.1 tibble_3.1.7
[22] lifecycle_1.0.1 crayon_1.5.1 purrr_0.3.4
[25] ggplot2_3.3.6 vctrs_0.4.1 curl_4.3.2
[28] Quandl_2.11.0 glue_1.6.2 compiler_4.1.3
[31] pillar_1.7.0 generics_0.1.2 scales_1.2.0
[34] jsonlite_1.8.0 pkgconfig_2.0.3
>
N.B. Choose your CRAN mirror accordingly (unless you also happen to be in Australia): https://cran.r-project.org/mirrors.html

R fable examples not running

I am trying to get started with the fable package in R for forecasting.
I am using the basic examples from their website:
I am trying to run the following example but it doesn't ever run, it runs eternally.
I have upgraded my version of RStudio and have had to restart multiple times but I have had no success.
library(fable)
library(tsibble)
library(tsibbledata)
library(lubridate)
library(dplyr)
aus_retail %>%
filter(
State %in% c("New South Wales", "Victoria"),
Industry == "Department stores"
) %>%
model(
ets = ETS(box_cox(Turnover, 0.3)),
arima = ARIMA(log(Turnover)),
snaive = SNAIVE(Turnover)
) %>%
forecast(h = "2 years") %>%
autoplot(filter(aus_retail, year(Month) > 2010), level = NULL)
Here is my sessioninfo()
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252
[3] LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C
[5] LC_TIME=English_Ireland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.2 magrittr_2.0.1 ellipsis_0.3.1 cli_2.4.0 tools_4.0.2
[6] pillar_1.5.1 glue_1.4.2 rstudioapi_0.13 tibble_3.1.0 crayon_1.4.1
[11] utf8_1.2.1 fansi_0.4.1 vctrs_0.3.4 hardhat_0.1.5 lifecycle_1.0.0
[16] pkgconfig_2.0.3 rlang_0.4.10
Any suggestions would be appreciated
I updated R to 4.1.0 and my issues have disappeared. I had to include some additional packages such as feasts and urca to remove any errors/warnings post upgrade to 4.1.0
sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252
[3] LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C
[5] LC_TIME=English_Ireland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] urca_1.3-0 feasts_0.2.2 lubridate_1.7.10 tsibbledata_0.3.0 tsibble_1.0.1
[6] fable_0.3.1 fabletools_0.3.1 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7
[11] purrr_0.3.4 readr_1.4.0 tidyr_1.1.3 tibble_3.1.2 ggplot2_3.3.5
[16] tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] tidyselect_1.1.1 lattice_0.20-44 haven_2.4.1 colorspace_2.0-2
[5] vctrs_0.3.8 generics_0.1.0 utf8_1.2.1 rlang_0.4.11
[9] pillar_1.6.1 glue_1.4.2 withr_2.4.2 DBI_1.1.1
[13] dbplyr_2.1.1 modelr_0.1.8 readxl_1.3.1 distributional_0.2.2
[17] lifecycle_1.0.0 progressr_0.8.0 munsell_0.5.0 gtable_0.3.0
[21] anytime_0.3.9 cellranger_1.1.0 rvest_1.0.0 labeling_0.4.2
[25] fansi_0.5.0 broom_0.7.8 Rcpp_1.0.7 scales_1.1.1
[29] backports_1.2.1 jsonlite_1.7.2 farver_2.1.0 fs_1.5.0
[33] digest_0.6.27 hms_1.1.0 stringi_1.6.2 numDeriv_2016.8-1.1
[37] grid_4.1.0 cli_3.0.1 tools_4.1.0 magrittr_2.0.1
[41] pacman_0.5.1 crayon_1.4.1 pkgconfig_2.0.3 ellipsis_0.3.2
[45] xml2_1.3.2 reprex_2.0.0 assertthat_0.2.1 httr_1.4.2
[49] rstudioapi_0.13 R6_2.5.0 nlme_3.1-152 compiler_4.1.0

R and RStudio crashes running read_parquet() on Mac M1

As the title states, both R and RStudio crash with a 'fatal error' when I try to run
read_parquet('abc.parquet')
For reference, read_parquet() is a function from the arrow() library
Using:
Macbook Pro M1 2020
Macbook Pro M1 2020
R version 4.1.0 (I think it is running through rosetta, activity monitor says 'Intel')
RStudio 1.4.1717
arrow 4.0.1
R sessionInfo():
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] arrow_4.0.1 data.table_1.14.0 dplyr_1.0.7 bsts_0.9.6 xts_0.12.1
[6] zoo_1.8-9 BoomSpikeSlab_1.2.4 Boom_0.9.7 MASS_7.3-54 reshape2_1.4.4
[11] DescTools_0.99.42 lubridate_1.7.10
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 compiler_4.1.0 pillar_1.6.1 plyr_1.8.6 class_7.3-19 tools_4.1.0
[7] bit_4.0.4 boot_1.3-28 tibble_3.1.2 lifecycle_1.0.0 rootSolve_1.8.2.1 lattice_0.20-44
[13] pkgconfig_2.0.3 rlang_0.4.11 Matrix_1.3-3 DBI_1.1.1 rstudioapi_0.13 mvtnorm_1.1-2
[19] expm_0.999-6 xfun_0.24 e1071_1.7-7 stringr_1.4.0 generics_0.1.0 vctrs_0.3.8
[25] bit64_4.0.5 tidyselect_1.1.1 gld_2.6.2 grid_4.1.0 glue_1.4.2 R6_2.5.0
[31] fansi_0.5.0 lmom_2.8 purrr_0.3.4 magrittr_2.0.1 ellipsis_0.3.2 assertthat_0.2.1
[37] Exact_2.1 utf8_1.2.1 tinytex_0.32 stringi_1.6.2 proxy_0.4-26 crayon_1.4.1
Here is a parquet file (one of many) which I am failing to import:
file.parquet

What is causing this error: "Failed to retrieve package sources for XML"

What is causing this error: "Failed to retrieve package sources for XML"? I'm trying to publish an example dashboard to R Connect.
[Connect] 2020/12/10 16:40:00.827991448 Error in getSourceForPkgRecord(pkgRecord, srcDir(project), availablePackagesSource(repos = repos), : Failed to retrieve package sources for XML 3.99-0.5 from CRAN (internet connectivity issue?) [3.99-0.3 is current]
[Connect] Build error: A required R package was found in the package repository, but the specified version is not available. (r-package-version-not-available)
Application deployment failed with error: A required R package was found in the package repository, but the specified version is not available. (r-package-version-not-available)
I tried removing and then reinstalling XLM and recently updated my R to version 4.0.3. Wondering if that means I need to deprecate down to 3.99 for XML?
Repo info
> options('repos')
$repos
CRAN
"https://cran.rstudio.com/"
attr(,"RStudio")
[1] TRUE
Session info
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinydashboard_0.7.1 PerformanceAnalytics_2.0.4 xts_0.12.1
[4] zoo_1.8-8 highcharter_0.8.2 ggplot2_3.3.2
[7] dygraphs_1.1.1.6 dplyr_1.0.2 shiny_1.5.0
loaded via a namespace (and not attached):
[1] tidyselect_1.1.0 purrr_0.3.4 lattice_0.20-41 colorspace_2.0-0 vctrs_0.3.5
[6] generics_0.1.0 htmltools_0.5.0 yaml_2.2.1 rlang_0.4.9 later_1.1.0.1
[11] pillar_1.4.7 glue_1.4.2 withr_2.3.0 TTR_0.24.2 lifecycle_0.2.0
[16] quantmod_0.4.18 stringr_1.4.0 munsell_0.5.0 gtable_0.3.0 htmlwidgets_1.5.2
[21] labeling_0.4.2 fastmap_1.0.1 Cairo_1.5-12.2 httpuv_1.5.4 curl_4.3
[26] broom_0.7.2 Rcpp_1.0.5 xtable_1.8-4 openssl_1.4.3 promises_1.1.1
[31] scales_1.1.1 backports_1.2.0 jsonlite_1.7.1 farver_2.0.3 mime_0.9
[36] askpass_1.1 digest_0.6.27 stringi_1.5.3 rlist_0.4.6.1 grid_4.0.3
[41] quadprog_1.5-8 tools_4.0.3 magrittr_2.0.1 tibble_3.0.4 crayon_1.3.4
[46] tidyr_1.1.2 pkgconfig_2.0.3 ellipsis_0.3.1 rsconnect_0.8.16 data.table_1.13.4
[51] lubridate_1.7.9.2 assertthat_0.2.1 rstudioapi_0.13 R6_2.5.0 igraph_1.2.6
[56] compiler_4.0.3

Warning in install.packages: converting NULL pointer to R NULL

I just upgraded to R 4.0.0 and I am now trying to reinstall the packages I use. But when I try to do so in RStudio, I have the following warning:
Warning in install.packages: converting NULL pointer to R NULL
I also had this sort of warning later when running a shiny app:
Warning in .Call("rs_registerShinyFunction", params): converting NULL pointer to R NULL
Where does this come from? How can I fix it?
If needed:
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C
[3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8
[5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8
[7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.4.0.2 hammer_0.0.0.9000 testthat_2.3.2
loaded via a namespace (and not attached):
[1] xfun_0.13 remotes_2.1.1 shinyjs_1.1 purrr_0.3.4
[5] miniUI_0.1.1.1 htmltools_0.4.0 usethis_1.6.1 yaml_2.2.1
[9] rlang_0.4.6 pkgbuild_1.0.8 later_1.0.0 glue_1.4.0
[13] withr_2.2.0 stringr_1.4.0 htmlwidgets_1.5.1 knitr_1.28
[17] callr_3.4.3 fastmap_1.0.1 golem_0.2.1 httpuv_1.5.2
[21] ps_1.3.3 fansi_0.4.1 Rcpp_1.0.4.6 xtable_1.8-4
[25] promises_1.1.0 backports_1.1.6 DT_0.13 shinyhelper_0.3.2
[29] desc_1.2.0 pkgload_1.0.2 jsonlite_1.6.1 config_0.3
[33] mime_0.9 fs_1.4.1 packrat_0.5.0 digest_0.6.25
[37] stringi_1.4.6 processx_3.4.2 stargazer_5.2.2 rprojroot_1.3-2
[41] here_0.1 cli_2.0.2 tools_4.0.0 dockerfiler_0.1.3
[45] magrittr_1.5 crayon_1.3.4 xml2_1.3.2 prettyunits_1.1.1
[49] shinyBS_0.61 attempt_0.3.1 assertthat_0.2.1 roxygen2_7.1.0
[53] rstudioapi_0.11 R6_2.4.1 compiler_4.0.0
Updating to the last Rstudio version (at least 1.2.5042) fixes the problem. It was noticed in this issue on Github.
To avoid incompatibilities with the new R major version, it might be a good idea to reinstall all the packages with:
installed <- installed.packages()[,1]
install.packages(installed)
This source recommends to install the packages with
Rscript -e 'install.packages(...)'
on the command line instead of RStudio. It seems to be something RStudio-specific.

Resources