Data types and importing data with R
Last updated on 2025-06-20 | Edit this page
Estimated time: 0 minutes
Overview
Questions
- Why is it important to understand what types of data you are working with?
- How are data imported into R?
Objectives
- Import data from multiple sources
- Identify and describe different data types
- Identify common errors
Introduction
In the lesson, the instructor will demonstraite how to read data using R, introduce the basic data types, and demonstrate common issues that may be associated with each data type. This will familiarize learners with the RStudio GUI, common data structres, and build the foundation for addressing common data QA/QC.
What you need to know is that there are three sections required for a valid Carpentries lesson template:
-
questions
are displayed at the beginning of the episode to prime the learner for the content. -
objectives
are the learning objectives for an episode displayed with the questions. -
keypoints
are displayed at the end of the episode to reinforce the objectives.
Inline instructor notes can help inform instructors of timing challenges associated with the lessons. They appear in the “Instructor View”
Challenge 1: Using R, open the provided dataset and answer the following information:
How many records and columns are in the dataset?
How many different types of data are in the dataset and what are they?
R
df <- read_csv(file_name.csv)
str(df)
OUTPUT
[1] "This new lesson looks good"
Challenge 2: Can you identify any issues with the dataset?
You can add a line with at least three colons and a
solution
tag.
Figures
You can also include figures generated from R Markdown:
R
pie(
c(Sky = 78, "Sunny side of pyramid" = 17, "Shady side of pyramid" = 5),
init.angle = 315,
col = c("deepskyblue", "yellow", "yellow3"),
border = FALSE
)

Or you can use standard markdown for static figures with the following syntax:
{alt='alt text for accessibility purposes'}
Callout
Callout sections can highlight information.
They are sometimes used to emphasise particularly important points but are also used in some lessons to present “asides”: content that is not central to the narrative of the lesson, e.g. by providing the answer to a commonly-asked question.
Key Points
- Use
.md
files for episodes when you want static content - Use
.Rmd
files for episodes when you need to generate output - Run
sandpaper::check_lesson()
to identify any issues with your lesson - Run
sandpaper::build_lesson()
to preview your lesson locally