Packages expand the basic functionality of R by providing numerous quality-of-life improvements that not only considerably simplify common data wrangling tasks but which also provide frameworks for state-of-the-art methods for statistical analysis and natural language processing (NLP), among many other things.
Installation
How do I install a library?
Navigate to Packages > Install and verify that the pop-up window says Install from: Repository (CRAN). You can now type in the name of the package you would like to install under Packages.
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(crosstable)
Attaching package: 'crosstable'
The following object is masked from 'package:purrr':
compact
library(flextable)
Attaching package: 'flextable'
The following object is masked from 'package:purrr':
compose
library(confintr)
Activating libraries
Whenever you start a new R session (i.e., open RStudio), your libraries and their respective functions will be inactive. To re-activate a library, either use the library() function or simply select it in the Packages tab.
It is good practice to only activate those packages that are necessary for your analysis. While it won’t be a problem for the small set of packages as shown here, loading dozens of packages increases the risk of obtaining “homonymous” functions which have the same name but perform different operations. In this case, it might be helpful to “disambiguate” them by directly indicating which package a function is from:
readxl::read_xlsx(...)
Citing R and R packages
Whenever we draw on ideas other than our own, we give credit to the respective source by citing it appropriately. The same applies to R, RStudio as well as all the packages we rely on throughout our analyses.
For R, an up-to-date citation can be generated as follows:
citation()
To cite R in publications use:
R Core Team (2023). R: A language and environment for statistical
computing. R Foundation for Statistical Computing, Vienna, Austria.
URL https://www.R-project.org/.
A BibTeX entry for LaTeX users is
@Manual{,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2023},
url = {https://www.R-project.org/},
}
We have invested a lot of time and effort in creating R, please cite it
when using it for data analysis. See also 'citation("pkgname")' for
citing R packages.
To cite a specific package, simply supply the package name as an argument.
citation("quanteda")
To cite package 'quanteda' in publications use:
Benoit K, Watanabe K, Wang H, Nulty P, Obeng A, Müller S, Matsuo A
(2018). "quanteda: An R package for the quantitative analysis of
textual data." _Journal of Open Source Software_, *3*(30), 774.
doi:10.21105/joss.00774 <https://doi.org/10.21105/joss.00774>,
<https://quanteda.io>.
A BibTeX entry for LaTeX users is
@Article{,
title = {quanteda: An R package for the quantitative analysis of textual data},
journal = {Journal of Open Source Software},
author = {Kenneth Benoit and Kohei Watanabe and Haiyan Wang and Paul Nulty and Adam Obeng and Stefan Müller and Akitaka Matsuo},
doi = {10.21105/joss.00774},
url = {https://quanteda.io},
volume = {3},
number = {30},
pages = {774},
year = {2018},
}
References
Winter, Bodo. 2020. Statistics for Linguists: An Introduction Using r. New York; London: Routledge.