5 Beyond the basics
Use expansion packages
for common procedures and more functionality
## Other packages used in this primer
install.packages("stargazer")
install.packages("reshape2")
install.packages("purrr")
The most common tasks have cheatsheets you can use. E.g.,
Sometimes you will want to install a package from GitHub. For this, you can use devtools or the lighter remotes
install.packages("devtools")
install.packages("remotes")
For devtools, you need to have developer tools installed on your pc. If you have not, try
For example, to color terminal output on Linux you can
library(remotes)
# Install https://github.com/jalvesaq/colorout
# to .libPaths()[1]
install_github('jalvesaq/colorout')
5.1 Task Views
Task views list relevant packages.
For all students and early researchers,
For microeconometrics,
For spatial econometrics
- https://cran.r-project.org/web/views/Spatial.html
- https://cran.r-project.org/web/views/SpatioTemporal.html
Multiple packages may have the same function name for different commands. In this case use the syntax package::function
to specify the package. For example
::install_github
devtools::install_github remotes
Don’t fret Sometimes there is not a specific package for your data.
Odds are, you can do most of what you want with base code.
- Packages just wrap base code in convient formats
- see https://cran.r-project.org/web/views/ for topical overviews
Statisticians might have different naming conventions
- if the usual software just spits out a nice plot you might have to dig a little to know precisely what you want
- your data are fundamentally numbers, strings, etc… You only have to figure out how to read it in.
But remember that many of the best plots are custom made (see https://www.r-graph-gallery.com/), and can also be interactive or animated