Installing Required Software-Packages - Panama Workshop
Installing Required Software-Packages - Panama Workshop
A collaboration between the Regional Office for Latin America and the Caribbean and
the Panama Country Office of the United Nations Population Fund (UNFPA), the
University of Southampton's WorldPop Research Group and the National Institute of
Statistics and Census in Panama with support from the Inter-American Development
Bank
3. If the installation works properly then we can go ahead and run the following code:
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/",
getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/",
getOption("repos")))
4. We then restart r and verify if rstan runs properly by running this code
library(rstan)
example(stan_model, package = "rstan", run.dontrun = TRUE)
If rstan is working correctly then you will see the model compile as seen in the image
below
3. Copy the code below and run it in r to put rtools on the right path
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con =
"~/.Renviron")
4. Then restart R (Sessions/Restart R)
5. Verify that rtools is being found using this code
Sys.getenv("BINPREF")
You will see something like this
## [1] ""
However if you see something like this, move to STEP 4
##[1] "C:/Rtools/mingw_$(WIN)/bin/"
6. If the rtools is correctly installed we should be able to install package from source
using this code:
install.packages("jsonlite", type = "source")
7. If installation fails or gives a warning message move to STEP 3. However, if the
installation works then we are good to go to install rstan.
Example of the error message:
Error in system(paste(MAKE, p1(paste("-f", shQuote(makefiles))),
"compilers"), :
'make' not found
* removing 'C:/Users/shq1g12/AppData/Local/R/win-library/4.3/jsonlite'
Warning in install.packages :
installation of package ‘jsonlite’ had non-zero exit status
STEP 3
1. Restart R (Session/restart R) and run the following scripts (copy all and past them
in your RStudio Source
install.packages("pkgbuild")
rt_path = gsub("\\","/",pkgbuild::rtools_path(),fixed=T)
rt_bin = paste0(substr(rt_path,1,nchar(rt_path)-4),"/mingw_$(WIN)/bin/")
writeLines(paste0('PATH="',rt_path,';${PATH}"'), con = "~/.Renviron")
writeLines(paste0('Sys.setenv(BINPREF = "',rt_bin,'")'), con = "~/.Rprofile")
3. If the installation does not work move to STEP 4. Example of the message error:
ERROR: compilation failed for package 'jsonlite'
* removing
'C:/Users/shq1g12/AppData/Local/R/win-library/4.3/jsonlite'
Warning in install.packages :
installation of package ‘jsonlite’ had non-zero exit status
4. However, if the installation works, we can go ahead and install rstan using the
code below
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/",
getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/",
getOption("repos")))
5. We need to restart r and verify whether rstan is installed properly by using the
following code
library(rstan)
example(stan_model, package = "rstan", run.dontrun = TRUE)
6. if rstan is installed correctly the model will compile and you would see the
following
STEP 4
1. Restart R (Sessions/Restart R)
2. We need to check whether the BINPREF environment variable is pointing to the old
RTools installation by running the following in R
Sys.getenv("BINPREF").
Your output should look like this
#[1] ""
3. However, if your output looks like:
#[1] "C:/Rtools/mingw_$(WIN)/bin/"
Then you need to check whether your .Rprofile file has been configured to set this
variable on R startup.
4. Run the following to see the rtool path
readLines("~/.Rprofile")
8. if you can install jsonlite from the source then now we can install rstan by running the
following code
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/",
getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/",
getOption("repos")))
9. You need to restart r and verify whether rstan is installed properly by using the
following code
library(rstan)
example(stan_model, package = "rstan", run.dontrun = TRUE)
10. if rstan is installed correctly the model will compile and you would see the following
Final test:
To ensure your rstan is working correctly, please copy the following script into your
R and run it line by line:
install.packages ("rstudioapi")
#Load rstan
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
##################END OF INSTALLATION###########################
B- Install QGIS
The preEA tool is compatible with all versions of the QGIS but we recommend installing QGIS 3.28
LTR
1- To install QGIS 3.28 on your machine, open your internet browser and navigate to the QGIS
downloads webpage: https://www.qgis.org/en/site/forusers/download.html
2- Click on the Looking for the most stable version? Get QGIS 3.28 LTR
3- Follow the on-screen instructions to install QGIS 3.28 on your computer. Once it has
installed, open it up to ensure it has installed correctly – on loading, you should see the
following graphic:
preEA tool plugin in QGIS
A zip folder that contains the preEA tool package will be shared with participants during the online
training.
1- Open QGIS software, from the menu item, click on the Plugins/Manage and Install
Plugins
2- In the dialogue that opens, find the Install from ZIP
3- You will be provided with a zip package containing a PreEA QGIS plugin to install (XX.zip),
please navigate the browser to this folder (C:\ XX).
4- Select the preEA tool plugin folder (XX.zip) and click on Open.
5- Click the Install Plugin button to install the preEA tool in your QGIS software
6- To confirm the tool has been downloaded, make sure you see the preEA tool icon on the
main menu