| Title: | Exercises for introductions to R |
|---|---|
| Description: | This package contains exercises that help users to practice concepts that are part of most introductory courses to R. |
| Authors: | Claudius Gräbner-Radkowitsch [aut, cre] (ORCID: <https://orcid.org/0000-0003-4065-4722>) |
| Maintainer: | Claudius Gräbner-Radkowitsch <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1 |
| Built: | 2026-10-13 13:52:31 UTC |
| Source: | https://github.com/teaching-datascience/DataScienceExercises |
The gapminder data on population size, life expectancy, and GDP per capita levels, aggregated over continents.
aggGDPlifexpaggGDPlifexp
A data frame with 60 rows and 5 variables:
Continent name
Year of the observation
Average life expectancy at birth, in years
Average population, in nb of people
Average GDP per capita, in 2005-international dollars
https://github.com/jennybc/gapminder
A data set on beer consumption; the data was obtained for a single household
beerbeer
A data frame with 30 rows and 5 variables
liters of beer consumed
Price of beer ($)
price of other liquor ($)
price of other goods and services (an index)
income ($)
http://www.principlesofeconometrics.com/poe4/poe4stata.htm
Reports your 'R' version, the version of this package, and whether all packages needed by the exercises are installed. If something does not work, run this function and send its output to your lecturer.
check_setup()check_setup()
A logical value, invisibly: 'TRUE' if the setup is complete.
## Not run: check_setup() ## End(Not run)## Not run: check_setup() ## End(Not run)
A data set on how much libraries need to pay for subscription plans of journals in the field of economics.
econjournalseconjournals
A data frame with 327 rows and 10 variables
Title of the journal
The subfield of economics the journal is devoted to, e.g. 'General', 'Finance' or 'Urban and Regional'.
The name of the publisher
Type of publisher: 'profit' or 'nonprofit'
First year in which journal was published in English language.
Price to university libraries for print and online access in the United States in 2004. Measured in nominal dollars.
Pages published in 2003
Journal impact factor in 2002
Total cites in 1999
Papers published in 2002
https://www.econ.ucsb.edu/~tedb/Journals/pricing.html
A an artificial data set about the height of students from the Europa University Flensburg. The composition of the population was set according to official information about the student population in 2021, the heights were created artificially by drawing from a random distribution, which was calibrated for mean and standard deviation parameters of the German population.
EUFstudentsEUFstudents
A data frame with 6402 rows and 2 variables
Gender of the person
Height of the person
Official statistics on the student population of the Europa-Universität Flensburg, https://www.uni-flensburg.de/die-universitaet/profil-der-euf/zahlen-und-fakten
A data set on the distribution of study semesters for all students of the Europa-University Flensburg in the spring semester 2021.
EUFstudentsemestersEUFstudentsemesters
A data frame with 5875 rows and 2 variables
The study semester of the student
An ID for the student
Official statistics on the student population of the Europa-Universität Flensburg, https://www.uni-flensburg.de/die-universitaet/profil-der-euf/zahlen-und-fakten
A subset of the gapminder data on population size, life expectancy, and GDP per capita levels in 2007.
gdplifexp2007gdplifexp2007
A data frame with 142 rows and 5 variables:
Country name
Continent name
Life expectancy at birth, in years
Population in 2007, in nb of people
GDP per capita, in 2005-international dollars
https://github.com/jennybc/gapminder
A small data set on the annual growth rate of German real GDP. It is used in the exercises on data import, where it is also provided as the csv file 'growth_data_1.csv'.
GrowthGrowth
A data frame with 6 rows and 3 variables
Country name, here always 'Germany'
Annual growth rate of real GDP, in percent
Year of the observation
World Bank World Development Indicators, indicator 'NY.GDP.MKTP.KD.ZG', obtained via the 'WDI' package; see 'data-raw/Growth.R'.
Lists all exercise collections that ship with this package.
list_exercises()list_exercises()
A character vector of exercise names, invisibly. The names and their titles are printed to the console.
## Not run: list_exercises() ## End(Not run)## Not run: list_exercises() ## End(Not run)
A random sample of 50k flights (out of 336776) from NYC in 2021.
nycflights21_smallnycflights21_small
A data frame with 50000 rows and 5 variables:
Arrival delay, in minutes. Negative times represent early arrivals.
Departure delay, in minutes. Negative times represent early departures.
Month of departure.
Two letter carrier abbreviation.
Distance between airports, in miles.
https://github.com/simonpcouch/anyflights
Computes the population variance as defined by
where is the population mean ()
and is the size of the population
pop_var(x)pop_var(x)
x |
A numerical vector |
The population variance of this vector
pop_var(c(2, 3, 4, 5)) pop_var(rnorm(20, 1, 0))pop_var(c(2, 3, 4, 5)) pop_var(rnorm(20, 1, 0))
A data set on the complexity of traded products and the share of these products in the exports of periphery countries. It is used in the exercises on data import, where it is also provided as the csv file 'product_complexity.csv'.
product_complexityproduct_complexity
A data frame with 10 rows and 3 variables
The code identifying the product according to the Harmonized System (HS)
The complexity of the product, measured as its product complexity index (PCI)
The share of this product in total exports, in percent
Own computations based on the BACI trade data of the CEPII; see 'data-raw/product_complexity.R'.
Returns the estimated coefficients of a linear regression model together with their standard errors, test statistics, p-values and the bounds of the 95
regression_table(model, digits = 3, level = 0.95)regression_table(model, digits = 3, level = 0.95)
model |
A fitted model object, usually the result of a call to [stats::lm()]. |
digits |
The number of digits to which the results are rounded. |
level |
The confidence level of the reported interval. |
This is a convenience function: the same information is available from 'summary(model)' and [stats::confint()], which you should also know how to use.
A 'data.frame' with one row per estimated coefficient and the columns 'term', 'estimate', 'std_error', 'statistic', 'p_value', 'lower_ci' and 'upper_ci'.
linmod <- lm(consumption ~ price_liquor, data = beer) regression_table(linmod)linmod <- lm(consumption ~ price_liquor, data = beer) regression_table(linmod)
Starts one of the interactive exercise collections of this package in your web browser. This is a convenience wrapper around [learnr::run_tutorial()]: it fills in the package name and makes sure the exercise opens in a browser window rather than the RStudio viewer pane.
run_exercise(name, launch_browser = TRUE, ...)run_exercise(name, launch_browser = TRUE, ...)
name |
The name of the exercise, e.g. '"Basics"'. Case does not matter. Call [list_exercises()] to see the available names. |
launch_browser |
Should the exercise open in your default web browser? 'TRUE' by default, which is usually what you want. |
... |
Further arguments passed on to [learnr::run_tutorial()]. |
To stop an exercise, press the red stop button in RStudio, or press 'Esc' in the console.
Called for its side effect of starting the exercise.
## Not run: run_exercise("Basics") ## End(Not run)## Not run: run_exercise("Basics") ## End(Not run)
A small data set on the size of the German population and its labor force. It is used in the exercises on data import, where it is also provided as the csv file 'unemp_pop.csv'.
unemp_popunemp_pop
A data frame with 6 rows and 4 variables
Country name, here always 'Germany'
Year of the observation
Total population, in nb of people
Total labor force, in nb of people
World Bank World Development Indicators, indicators 'SP.POP.TOTL' and 'SL.TLF.TOTL.IN', obtained via the 'WDI' package; see 'data-raw/unemp_pop.R'.
A data set containing information about the alcohol and residual sugar contained in white and red wines, as well as their quality
wine2dinewine2dine
A data frame with 6497 rows and 4 variables:
The alcohol content of the wine
An quality score between 0 and 10, based on sensory data
The amount of sugar left in the wine
The kind of wine, i.e. red or white
https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/