This short tutorial will guide you in the installation of:
- R : a programming language and software environment for statistical
computing and graphics
- RStudio: a user-friendly interface for R
- R packages: collection of R functions
R is a programming language and software environment for statistical computing and graphics. It is free, runs on all major operating systems (Windows, Unix and MacOS), contains advanced statistical routines not yet available in other software (in network analysis for instance) and has state-of-the-art graphics capabilities.
Visit the R webpage: http://www.r-project.org/ and click ‘download R’
Choose the closest CRAN mirror (server) to your location. If you are in Utrecht for instance, you will click on ‘http://cran-mirror.cs.uu.nl/’. If there is no CRAN for your location it’s ok, just find the closest (distance slightly affects download time but any server can do the job.
Choose the R version that fits your OS (Windows, Unix or MacOS). Then download and install R on your laptop. Make sure to install the latest version of R (i.e. the most recent one).
R is the software that does all the computation. But we will use an interface to make our life easier. This software is called RStudio.
Download RStudio Desktop by visiting https://www.rstudio.com/products/rstudio/download/. Again, choose the one that corresponds to you OS. Install RStudio on your laptop (latest version).
R packages are set of functions & codes that have been defined by developers to solve specific problems. For instance, computing network statistics require several lines of complex coding. The R package ‘igraph’ allows you to compute network statistics in a single line of coding that can be as simple as ‘degree’.
We will now need to install the igraph, reshape, Matrix, devtools, EconGeo, RSiena, and networkD3 packages. To install all packages, just copy and paste the entire text below in the R console (bottom-left window):
install.packages(“visNetwork”)
install.packages(“htmlwidgets”)
install.packages(“igraph”)
install.packages(“reshape”)
install.packages(“Matrix”)
install.packages(“RSiena”)
install.packages(“networkD3”)
install.packages(“curl”)
install.packages(“EconGeo”)
If you see an error message (you do not have permission to write to the R-3.3.1directory): the problem comes from a security setting on your laptop. You can fix that by (1) changing the library directory to a directory where you have writing privileges or (2) changing the security settings on the R folder to “full control”:
Still not working? Well then you use a R notebook from your
browser:
- You just need a Google account
- Save this file on
your computer
- Go to Google
colab
- Then: File -> Open Notebook, upload the econx.ipynb file you saved
earlier
- +code, then click on the play button
- You are all set; uou now have a R browser version in which you can run
any R code