| tutorial-id |
none |
data-import |
| name |
question |
Hassan Ali |
| email |
question |
hassan.alisoni007@gmail.com |
| reading-data-from-a-file-1 |
question |
Documentation for package ‘readr’ version 2.1.5 |
| reading-data-from-a-file-2 |
exercise |
setwd("E:/DataScience/")
library(readr)
read_csv("E:/DataScience/data.csv") |
| reading-data-from-a-file-3 |
exercise |
setwd("E:/DataScience/")
library(readr)
students <- read_csv("data.csv") |
| reading-data-from-a-file-4 |
exercise |
print(students) |
| reading-data-from-a-file-5 |
exercise |
setwd("E:/DataScience/")
library(readr)
students <- read_csv("data.csv", na = c("N/A", "")) |
| reading-data-from-a-file-6 |
exercise |
setwd("E:/DataScience/")
library(readr)
students <- read_csv("data.csv", na = c("N/A", "")) |>
rename(student_id = "Student ID") |
| reading-data-from-a-file-7 |
exercise |
setwd("E:/DataScience/")
library(janitor) |
| reading-data-from-a-file-8 |
exercise |
setwd("E:/DataScience/")
library(janitor)
students <- read_csv("data.csv", na = c("N/A", "")) |>
clean_names() |
| reading-data-from-a-file-9 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(dplyr)
library(janitor)
students <- read_csv("data.csv", na = c("N/A", "")) |>
clean_names() |>
mutate(meal_plan = factor(meal_plan)) |
| reading-data-from-a-file-10 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(dplyr)
library(janitor)
students <- read_csv("data.csv", na = c("N/A", "")) |>
clean_names() |>
mutate(
meal_plan = factor(meal_plan),
age = if_else(age == "five", "5", age)
) |
| reading-data-from-a-file-11 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(dplyr)
library(janitor)
students <- read_csv("data.csv", na = c("N/A", "")) |>
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 |
setwd("E:/DataScience/")
test_1 <- read_csv("test_1.csv") |
| reading-data-from-a-file-13 |
exercise |
setwd("E:/DataScience/")
test_1 <- read_csv("test_1.csv", show_col_types = FALSE) |
| reading-data-from-a-file-14 |
exercise |
setwd("E:/DataScience/")
test_2 <- read_csv("test_2.csv") |
| reading-data-from-a-file-15 |
exercise |
setwd("E:/DataScience/")
test_3 <- read_csv("test_3.csv", col_names = FALSE) |
| reading-data-from-a-file-16 |
exercise |
setwd("E:/DataScience/")
test_3 <- read_csv("test_3.csv", col_names = c("a", "b", "c")) |
| reading-data-from-a-file-17 |
exercise |
setwd("E:/DataScience/")
test_3 <- read_csv(
"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 |
setwd("E:/DataScience/")
test_5 <- read_csv("test_5.csv", na = ".") |
| reading-data-from-a-file-19 |
exercise |
setwd("E:/DataScience/")
test_6 <- read_csv("test_6.csv", comment = "#") |
| reading-data-from-a-file-20 |
exercise |
setwd("E:/DataScience/")
test_7 <- read_csv(
"test_7.csv",
col_types = cols(
grade = col_integer(),
student = col_character()
)
) |
| reading-data-from-a-file-21 |
exercise |
setwd("E:/DataScience/")
test_bad_names <- read_csv(
"test_bad_names.csv",
name_repair = "universal"
) |
| reading-data-from-a-file-22 |
exercise |
setwd("E:/DataScience/")
test_bad_names <- read_csv("test_bad_names.csv") |>
clean_names() |
| reading-data-from-a-file-23 |
exercise |
setwd("E:/DataScience/")
library(readr)
read_csv(
"test_bad_names.csv",
name_repair = janitor::make_clean_names
) |
| reading-data-from-a-file-24 |
exercise |
setwd("E:/DataScience/")
library(readr)
read_delim("delim_1.txt", delim = "|") |
| reading-data-from-a-file-25 |
exercise |
setwd("E:/DataScience/")
library(readr)
read_delim(
"delim_2.txt",
delim = "|",
col_types = cols(
date = col_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 |
setwd("E:/DataScience/")
library(readr)
simple_csv <- "
x
10
.
20
30"
read_csv(simple_csv)
read_csv(simple_csv, col_types = list(x = col_double())) |
| controlling-column-types-5 |
exercise |
setwd("E:/DataScience/")
library(readr)
simple_csv <- "
x
10
.
20
30"
df <- read_csv(simple_csv, col_types = list(x = col_double()))
problems(df) |
| controlling-column-types-6 |
exercise |
setwd("E:/DataScience/")
library(readr)
simple_csv <- "
x
10
.
20
30"
df <- read_csv(simple_csv, na = ".") |
| controlling-column-types-7 |
exercise |
another_csv <- "
x,y,z
1,2,3" |
| controlling-column-types-8 |
exercise |
another_csv <- "
x,y,z
1,2,3"
setwd("E:/DataScience/")
library(readr)
read_csv(another_csv, col_types = cols_only(x = col_character())) |
| controlling-column-types-9 |
exercise |
setwd("E:/DataScience/")
df <- read_csv("ex_2.csv", col_types = cols(.default = col_character()))
problems(df) |
| controlling-column-types-10 |
exercise |
setwd("E:/DataScience/")
library(readr)
df <- read_csv("ex_2.csv",
col_types = cols(.default = col_character())) |
| controlling-column-types-11 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(dplyr)
df <- read_csv("ex_2.csv",
col_types = cols(.default = col_character())) |>
mutate(a = parse_integer(a)) |
| controlling-column-types-12 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(dplyr)
df <- read_csv("ex_2.csv",
col_types = cols(.default = col_character())) |>
mutate(
a = parse_integer(a),
b = parse_date(b, format = "%Y-%m-%d") # Corrected date format
) |
| controlling-column-types-13 |
exercise |
setwd("E:/DataScience/")
library(readr)
df <- read_csv("ex_3.csv")
problems(df) |
| controlling-column-types-14 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(dplyr)
read_csv("ex_3.csv") |>
mutate(x = parse_date(x, "%d %B %Y")) |
| controlling-column-types-15 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(dplyr)
read_csv("ex_3.csv") |>
mutate(
x = parse_date(x, "%d %B %Y"),
z = parse_number(z)
) |
| reading-data-from-multiple-fil-1 |
exercise |
list.files("data") |
| reading-data-from-multiple-fil-2 |
exercise |
list.files("data", pattern = "similar") |
| reading-data-from-multiple-fil-3 |
exercise |
list.files("data", pattern = "similar", full.names = TRUE) |
| reading-data-from-multiple-fil-4 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(purrr)
list.files("data", pattern = "similar", full.names = TRUE) |>
map_dfr(~ read_csv(.x, na = ".", col_types = cols(.default = col_double()))) |
| reading-data-from-multiple-fil-5 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(purrr)
list.files("data", pattern = "similar", full.names = TRUE) |>
map_dfr(~ read_csv(.x, na = ".")) |
| reading-data-from-multiple-fil-6 |
exercise |
setwd("E:/DataScience/")
library(readr)
library(purrr)
list.files("data", pattern = "similar", full.names = TRUE) |>
map_dfr(~ read_csv(.x, na = ".", show_col_types = FALSE)) |
| reading-data-from-multiple-fil-7 |
exercise |
list.files("data", pattern = "sales") |
| reading-data-from-multiple-fil-8 |
exercise |
list.files("data", pattern = "sales", full.names = TRUE) |>
map_dfr(read_csv) |
| reading-data-from-multiple-fil-9 |
exercise |
list.files("data", pattern = "sales", full.names = TRUE) |>
map_dfr(~ read_csv(.x, id = "file")) |
| writing-to-a-file-1 |
exercise |
students2 <- students |>
clean_names() |>
mutate(
meal_plan = factor(meal_plan),
age = if_else(age == "five", "5", age),
age = parse_number(age)
)
students2 |
| writing-to-a-file-2 |
exercise |
students2 |
| writing-to-a-file-3 |
exercise |
# Write the students2 data to a CSV file in the data directory
write_csv(x = students2, file = "students2.csv") |
| writing-to-a-file-4 |
exercise |
students2_reloaded <- read_csv("data/students2.csv") |
| writing-to-a-file-5 |
exercise |
iris_p <- iris |>
ggplot(aes(x = Sepal.Length, y = Sepal.Width)) +
geom_jitter() +
labs(title = "Sepal Dimensions of Various Species of Iris",
x = "Sepal Length",
y = "Sepal Width") |
| writing-to-a-file-6 |
exercise |
list.files("data") |
| writing-to-a-file-7 |
exercise |
read_rds("data/test_1.rds") |
| writing-to-a-file-8 |
exercise |
write_rds(mtcars, "data/test_2.rds") |
| writing-to-a-file-9 |
exercise |
list.files("data") |
| writing-to-a-file-10 |
exercise |
read_rds("data/test_2.rds") |
| writing-to-a-file-11 |
question |
What is the difference between Apache Arrow and Parquet? |
| data-entry-1 |
exercise |
tibble(
x = c(1, 2, 5),
y = c("h", "m", "g"),
z = c(0.08, 0.83, 0.60)
) |
| data-entry-2 |
exercise |
tribble(
~x, ~y, ~z,
1, "h", 0.08,
2, "m", 0.83,
5, "g", 0.60
) |
| minutes |
question |
170 |