Skip to content

Instantly share code, notes, and snippets.

@graebnerc
Last active April 20, 2023 14:22
Show Gist options
  • Save graebnerc/ae8b0b7cddcd87a107d3715b3d9ce819 to your computer and use it in GitHub Desktop.
Save graebnerc/ae8b0b7cddcd87a107d3715b3d9ce819 to your computer and use it in GitHub Desktop.
Scripts containing the code developed during the 7th lecture on project management and data import, as well as solutions to the exercises
Scripts containing the code developed during the 7th lecture on project management and data import, as well as solutions to the exercises.
The code assumes that you created a folder structure as discussed during the lecture:
YourProject/
|─ YourProject.Rproj
├─ data/
│ ├─ raw/
| |─fread_expls-1.csv
| |─fread_expls-2.csv
| |─fread_expls-3.csv
| ├─ tidy/
├─ R/
│ ├─ exercise_1.R
│ ├─ exercise_2.R
│ ├─ exercise_3.R
here::i_am("R/exercise_1.R")
library(here)
library(data.table)
data_path <- here::here("data/raw/fread_expls-1.csv")
ex_1_data <- data.table::fread(
file = data_path)
ex_1_data
here::i_am("R/exercise_2.R")
library(here)
library(data.table)
data_path <- here::here("data/raw/fread_expls-2.csv")
ex_2_data <- data.table::fread(
file = data_path,
sep = "'",
dec = ":")
ex_2_data
here::i_am("R/exercise_3.R")
library(here)
library(data.table)
data_path <- here::here("data/raw/fread_expls-3.csv")
ex_3_data <- data.table::fread(
file = data_path,
colClasses = c(
"commoditycode"="character",
"cgroup"="factor")
)
str(ex_3_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment