Statistics Denmark API using R

Data Carpentry’s aim is to teach researchers basic concepts, skills, and tools for working with data so that they can get more done in less time, and with less pain. The lessons below were designed for those interested in working with data in R.

This is an introduction to harvesting data from the Statistics Denmark, using R. It is designed for participants with a working knowledge of R, at least on the level of our introductory course (R for absolute beginners)[https://kubdatalab.github.io/beginning-R/].

These lessons can be taught in 2 hours. They start with a short refresher of R, introduces what an API is, and how to get data from it, and finishes with calculating summary statistics from that data. A brief introduction to plotting rounds of the course.

This site is a work in progress.

Getting Started

Data Carpentry’s teaching is hands-on, so participants are encouraged to use their own computers to ensure the proper setup of tools for an efficient workflow.

To get started, follow the directions in the “Setup” tab to download data to your computer and follow any installation instructions.

Prerequisites

This lesson requires a working copy of R and RStudio.
To most effectively use these materials, please make sure to install everything before working through this lesson.

For Instructors

If you are teaching this lesson in a workshop, please see the Instructor notes.

Schedule

Setup Download files required for the lesson
00:00 1. Before we Start What have I forgotten about R and RStudio?
How to interact with R?
How to manage your environment?
How to install packages?
00:15 2. Introduction to R What data types are available in R?
What is an object?
How can values be initially assigned to variables of different data types?
What arithmetic and logical operators can be used?
How can subsets be extracted from vectors?
How does R treat missing values?
How can we deal with missing values in R?
01:35 3. Starting with Data What else have we forgotten about R?
What is a data.frame?
How can I read a complete csv file into R?
How can I get basic summary information about my dataset?
How can I change the way R treats strings in my dataset?
Why would I want strings to be treated differently?
How are dates represented in R and how can I change the format?
02:55 4. What is an API? What is an API?
03:40 5. What about danstat? An easier way to access Statistics Denmark
04:25 6. Time How can I select specific rows and/or columns from a dataframe?
05:45 7. Data Visualisation with ggplot2 What are the components of a ggplot?
How do I create scatterplots, boxplots, and barplots?
How can I change the aesthetics (ex. colour, transparency) of my plot?
How can I create multiple plots at once?
07:40 8. Whats next? What is the next step?
08:25 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.