| tutorial-id |
none |
data-import |
| name |
question |
Kellen Narke |
| email |
question |
kellen.narke@gmail.com |
| reading-data-from-a-file-1 |
question |
Documentation for package ‘readr’ version 2.1.5 |
| reading-data-from-a-file-2 |
exercise |
read_csv(file = "data/students.csv") |
| reading-data-from-a-file-3 |
exercise |
students <- read_csv(file = "data/students.csv") |
| reading-data-from-a-file-4 |
exercise |
students |
| reading-data-from-a-file-5 |
exercise |
read_csv(file = "data/students.csv", na = c("N/A", "")) |
| reading-data-from-a-file-6 |
exercise |
students |> rename(student_id = "Student ID") |
| reading-data-from-a-file-7 |
exercise |
library(janitor) |
| reading-data-from-a-file-8 |
exercise |
students |>
clean(names) |
| reading-data-from-a-file-9 |
exercise |
students |>
clean_names() |>
mutate(meal_plan = factor(meal_plan)) |
| reading-data-from-a-file-10 |
exercise |
students |>
clean_names() |>
mutate(meal_plan = factor(meal_plan)) |>
mutate(age = if_else(age == "five", "5", age)) |
| reading-data-from-a-file-11 |
exercise |
students |>
clean_names() |>
mutate(
meal_plan = factor(meal_plan),
age = if_else(age == "five", "5", age),
age = parse_number(age)
) |
| reading-data-from-a-file-12 |
exercise |
read_csv(file = "data/test_1.csv") |
| reading-data-from-a-file-13 |
exercise |
read_csv(file = "data/test_1.csv", show_col_types = FALSE) |
| reading-data-from-a-file-14 |
exercise |
read_csv(file = "data/test_1.csv", show_col_types = FALSE, skip = 2) |
| reading-data-from-a-file-15 |
exercise |
col_names = false |
| reading-data-from-a-file-16 |
exercise |
col_names = false |
| reading-data-from-a-file-17 |
exercise |
read_csv("data/test_3.csv",
col_names = c("a", "b", "c"),
col_types = cols(a = col_double(),
b = col_double(),
c = col_double())) |
| reading-data-from-a-file-18 |
exercise |
read_csv(file = "data/test_5.csv", na = ".") |
| reading-data-from-a-file-19 |
exercise |
|
| reading-data-from-a-file-20 |
exercise |
col_types = cols(grade = col_integer(), student = col_character()) |
| reading-data-from-a-file-21 |
exercise |
read_csv(file = "data/test_bad_names.csv",
name_repair = "universal") |
| reading-data-from-a-file-22 |
exercise |
read_csv(file = "data/test_bad_names.csv") |> clean_names() |
| reading-data-from-a-file-23 |
exercise |
read_csv(file = "data/test_bad_names.csv", name_repair = janitor::make_clean_names) |
| reading-data-from-a-file-24 |
exercise |
read_delim(file = "data/delim_1.txt") |
| reading-data-from-a-file-25 |
exercise |
Set the `col_types` argument to
cols(date = col_date(format = <date>),
population = col_integer(),
town = col_character()) |
| controlling-column-types-1 |
exercise |
read_csv("
a, b, c
1, 2, 3") |
| controlling-column-types-2 |
exercise |
read_csv("
logical,numeric,date,string
TRUE,1,2021-01-15,abc
false,4.5,2021-02-15,def
T,Inf,2021-02-16,ghi
") |
| controlling-column-types-3 |
exercise |
simple_csv <- "
x
10
.
20
30"
read_csv(simple_csv) |
| controlling-column-types-4 |
exercise |
read_csv(simple_csv, col_types = list(x=col_double())) |
| minutes |
question |
120 |