From 15534c5bf3c8a21ea87efdac8aae7f828cc012bb Mon Sep 17 00:00:00 2001 From: Jordi Date: Thu, 28 Dec 2023 22:50:45 +0100 Subject: [PATCH] test --- _targets.R | 4 ++++ functions.R | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/_targets.R b/_targets.R index 976f8aa..8cc902c 100644 --- a/_targets.R +++ b/_targets.R @@ -6,6 +6,10 @@ source("functions.R") list( + tar_target( + targets_test, + test_read() + ), tar_target( unemp_data, get_data() diff --git a/functions.R b/functions.R index c895828..948e0f2 100644 --- a/functions.R +++ b/functions.R @@ -1,4 +1,9 @@ print("functions.R") + +test_read <- function() { + raw <- readr::read_csv("https://raw.githubusercontent.com/b-rodrigues/modern_R/master/datasets/unemployment/unemp_2013.csv") + raw |> janitor::clean_names() +} # clean_unemp() is a function inside a package I made. Because I don't want you to install # the package if you're following along, I'm simply sourcing it: clean_unemp <- function(unemp_data, @@ -50,9 +55,8 @@ clean_unemp <- function(unemp_data, clean_data <- function(x){ print("clean_data") print(x) - x %>% - janitor::clean_names() %>% - print(n = Inf) %>% + x |> + janitor::clean_names() |> mutate(level = case_when( grepl("Grand-D.*", commune) ~ "Country", grepl("Canton", commune) ~ "Canton", @@ -64,7 +68,7 @@ clean_data <- function(x){ commune = ifelse(grepl("Grand-D.*", commune), stringr::str_remove_all(commune, "Grand-Duche de "), commune), - ) %>% + ) |> select(year, place_name = commune, level,