Publications by Michael Kulig
Apply to Data 12
Import your data data("mtcars") mtcars <- as_tibble(mtcars) Repeat the same operation over different columns of a data frame Case of numeric variables mtcars %>% map_dbl(.x = ., .f = ~mean(x = .x)) ## mpg cyl disp hp drat wt qsec ## 20.090625 6.187500 230.721875 146.687500 3.596563 3.217250 ...
353 sym Python (7575 sym/45 pcs) 2 img
Code Along 12
Ch20 Vectors Introduction Vector basics Important types of automic vector Using automic vectors sample(10) + 10 ## [1] 14 15 20 17 16 13 19 18 11 12 1:10 + 1:2 ## [1] 2 4 4 6 6 8 8 10 10 12 1:10 + 1:3 ## Warning in 1:10 + 1:3: longer object length is not a multiple of shorter object ## length ## [1] 2 4 6 5 7 9 8 10 12 11 data....
335 sym Python (2482 sym/60 pcs)
Apply to Data 11
Import your data data(flights) flights %>% skimr::skim() Data summary Name Piped data Number of rows 336776 Number of columns 19 _______________________ Column type frequency: character 4 numeric 14 POSIXct 1 ________________________ Group variables None Variable type: character skim_variable n_missing complete_rate min max empty n_un...
605 sym 8 tbl
Code Along 11
Introduction When should you write a function? # For reproducible work set.seed(1234) # Create a data frame df <- tibble::tibble( a = rnorm(10), b = rnorm(10), c = rnorm(10), d = rnorm(10) ) #Rescale each column df$a <- (df$a - min(df$a, na.rm = TRUE)) / (max(df$a, na.rm = TRUE) - min(df$a, na.rm = TRUE)) df$b <- (df$b - min(df$b, na....
289 sym
Apply to Data 10
Import your data data <- read_csv("../00_data/MKmyData1.csv") ## Rows: 101 Columns: 17 ## ── Column specification ──────────────────────────────────────────────────────── ## Delimiter: "," ## chr (8): id.on.tag, animal.name, scientifi...
290 sym 2 img
Code Along 10
Chapter 15 factors Creating factors General Social survey gss_cat ## # A tibble: 21,483 × 9 ## year marital age race rincome partyid relig denom tvhours ## <int> <fct> <int> <fct> <fct> <fct> <fct> <fct> <int> ## 1 2000 Never married 26 White $8000 to 9999 Ind,near … Prot… Sout… ...
439 sym 4 img
Apply to Data 9
Import your data MKmydata1 <- read_csv("../00_data/MKmyData1.csv") ## Rows: 101 Columns: 17 ## ── Column specification ──────────────────────────────────────────────────────── ## Delimiter: "," ## chr (8): id.on.tag, animal.name, scie...
112 sym
Code Along 9
Introduction String basics chac_data <- "I'm 'very' hungry." stringr::str_length("I am hungry.") ## [1] 12 stringr::str_c(c("I", " am"), collapse = "") ## [1] "I am" stringr::str_c("I", " am", sep = " ;") ## [1] "I ; am" str_sort(c("John", "Mary", "Aaron")) ## [1] "Aaron" "John" "Mary" Matching Patterns with regular expressions flights %>% gli...
365 sym
Apply to Data 8
1. Import your data Import two related datasets from TidyTuesday Project. cats_uk <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-01-31/cats_uk.csv') ## Rows: 18215 Columns: 11 ## ── Column specification ────────────────────────────�...
1644 sym
Code Along 8
Introduction nycflights13 Keys Mutating joins Inner join x <- tribble( ~key, ~val_x, 1, "x1", 2, "x2", 3, "x3" ) y <- tribble( ~key, ~val_y, 1, "y1", 2, "y2", 4, "y3" ) inner_join(x, y) ## Joining with `by = join_by(key)` ## # A tibble: 2 × 3 ## key val_x val_y ## <dbl> <chr> <chr> ## 1 1 x1 y1 ...
203 sym Python (5251 sym/42 pcs)