My personal hot takes π₯
2026-05-21
π Visible: Can I find it?
π Reusable: Can I adapt it?
π‘οΈ Reliable: Can I trust it?
Commented code
\(\neq\) good code
library(dplyr) # load dplyr package
d1 <- as.data.frame(crimtab) # turn table into dataframe
d2 <- d1 |> # create new dataset
mutate(# make new variables
fg = f1(Var1), # convert Var1 into numeric this represents finger length
ht = f1(Var2), # convert Var2 into numeric this represents height
n = Freq # rename frequency column this is the count
) |>
select(fg, ht, n) # keep only required columns
# function to turn factor into numeric
# this is needed because the variables are factors
# and we want numeric values instead
f1 <- function(x) {
y <- as.character(x) # convert factor to character
as.numeric(y) # convert character to numeric
}library(dplyr)
criminal_summary <- crimtab |>
as.data.frame() |>
mutate(
finger_length = extract_numeric_from_factor(Var1),
height = extract_numeric_from_factor(Var2),
count = Freq
) |>
select(finger_length, height, count)
extract_numeric_from_factor <- function(factor) {
as.numeric(as.character(factor))
}Reusable β»οΈ
not reproducible
Open first π
You donβt need friends π©βπ»
to use Git
can build an R package π¦
It doesnβt have toβ¦
(spreadsheets). Make QA work for you.
It doesnβt have to be
perfect β¨