Subsetting data with dplyr¶
The following makes use of the dplyr package. You may need to install it from CRAN using the code
install.packages("dplyr") if you want to run this on your computer. (The package is already installed on the notebook container, however.)
Here we use data from the British Election Study 2010. The data set bes2010feelings.RData is prepared from the original available at https://www.britishelectionstudy.com/data-object/2010-bes-cross-section/ by removing identifying information and scrambling the data.
Attaching package: ‘dplyr’ The following objects are masked from ‘package:stats’: filter, lag The following objects are masked from ‘package:base’: intersect, setdiff, setequal, union
bes2010feelings.sub <- bes2010feelings %>% filter(region == "Scotland") %>% select(wave, flng.brown, flng.cameron, flng.clegg, flng.salmond)
wave flng.brown flng.cameron flng.clegg flng.salmond 55002.1 Pre 8 3 NA 7 55003.1 Pre 0 3 NA 2 55006.1 Pre 4 5 5 7 55007.1 Pre 6 5 6 6 55010.1 Pre 8 6 7 0 55015.1 Pre 9 3 3 4
Downloadable R script and interactive version
The link with the “jupyterhub” icon directs you to an interactive Jupyter1 notebook, which runs inside a Docker container2. There are two variants of the interative notebook. One shuts down after 60 seconds and does not require a sign it. The other requires sign in using your ORCID3 credentials, yet shuts down only after 24 hours. (There is no guarantee that such a container persists that long, it may be shut down earlier for maintenance purposes.) After shutdown all data within the container will be reset, i.e. all files created by the user will be deleted.4
Above you see a rendered version of the Jupyter notebook.5
ORCID is a free service for the authentication of researchers. It also allows to showcase publications and contributions to the academic community such as peer review.. See
https://info.orcid.org/what-is-orcid/for more information.
The Jupyter notebooks come with NO WARRANTY whatsoever. They are provided for educational and illustrative purposes only. Do not use them for production work.
The notebook is rendered with the help of the nbsphinx extension.