njt-user-2022.netlify.app
nj_tierney
greta
software(adapted from Heidi Seibold's UseR2021 Keynote talk)
greta
Grete Hermann (1901 - 1984)
wrote the first algorithms for computer algebra
... without a computer
(To avoid people saying 'greet', the package is spelled greta instead)
$$ \alpha \sim Normal(0, 5) $$
$$ \beta \sim Normal(0, 3) $$
$$ \sigma \sim logNormal(0, 5) $$ $$ \mu = \alpha + \beta X $$
$$ Y \sim Normal(\mu, \sigma) $$
x <- penguins$bill_length_mmy <- penguins$flipper_length_mmalpha <- normal(0,5)beta <- normal(0,3)sd <- lognormal(0,3)mu <- alpha + coef * xdistribution(y) <- normal(mu, sd)m <- model(mu, beta, sd)draws <- mcmc(m)
yahtsee
(Yet Another Hierarchical Time Series Extension + Expansion)
cleaned_data <- data %>% as_tibble() %>% group_by(who_region) %>% transmute(.who_region_id = cur_group_id()) %>% ungroup(who_region) %>% select(-who_region) %>% group_by(country) %>% transmute(.country_id = cur_group_id()) %>% ungroup(country) %>% select(-country)
model <- inlabru::bru(formula = pr ~ avg_lower_age + Intercept + who_region(month_num, model = "ar1", group = .who_region_id, constr = FALSE) + country(month_num, model = "ar1", group = .country_id, constr = FALSE), family = "gaussian", data = malaria_africa_ts, options = list(control.compute = list(config = TRUE), control.predictor = list(compute = TRUE, link = 1)) )
yahtsee
(Yet Another Hierarchical Time Series Extension + Expansion)
m <- fit_hts( formula = pr ~ avg_lower_age + hts(who_region, country), .data = malaria_africa_ts, family = "gaussian")
Reflections; Advice
greta
is complex: Where do you startCode Smells (I first heard through Jenny Bryan's UseR 2018 keynote):
is an evocative term for that vague feeling of unease we get when reading certain bits of code. It's not necessarily wrong, but neither is it obviously correct
Code Smells (I first heard through Jenny Bryan's UseR 2018 keynote):
is an evocative term for that vague feeling of unease we get when reading certain bits of code. It's not necessarily wrong, but neither is it obviously correct
param_lengths <- vapply( params, function(x) length(x), FUN.VALUE = 1L )
param_lengths <- lengths(params)
You want to test messages or output, e.g., that your code looks like this:
> greta array (data) [,1] [,2] [,3][1,] 1 4 7[2,] 2 5 8[3,] 3 6 9
# data arrays# print methodga_data <- as_data(matrix(1:9, nrow = 3))expected_output <- paste0( "greta array (data)\n\n [,1] [,2] [,3]\n[1,]", " 1 4 7\n[2,] 2 5 8\n[3,] 3", " 6 9")result <- evaluate_promise(ga_data, print = TRUE)expect_identical(result$output, expected_output)
# data arrays# print methodga_data <- as_data(matrix(1:9, nrow = 3))expect_snapshot( ga_data)
# print and summary work Code ga_data Output greta array (data) [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9
# wrong class of objectexpect_error( as_data(NULL), "objects of class NULL cannot be coerced to greta arrays" )expect_error( as_data(list()), "objects of class list cannot be coerced to greta arrays" )expect_error( as_data(environment()), "objects of class environment cannot be coerced to greta arrays" )
# wrong class of objectexpect_snapshot_error( as_data(NULL))expect_snapshot_error( as_data(list()))expect_snapshot_error( as_data(environment()))
# as_data errors informatively Object cannot be coerced to <greta_array> Objects of class <NULL> cannot be coerced to a <greta_array>--- Object cannot be coerced to <greta_array> Objects of class <list> cannot be coerced to a <greta_array>--- Object cannot be coerced to <greta_array> Objects of class <environment> cannot be coerced to a <greta_array>---
Git/mercurial/SVN/whatever
github/bitbucket/gitlab/whatever
Git/mercurial/SVN/whatever
github/bitbucket/gitlab/whatever
If you develop a new changes, make a new branch.
Do:
Don't
*
heard from Adam Gruer
pr_fetch()
and pr_finish()
These are amazing functions that help save me a bit of time every day
pr_fetch(101)
: Grabs Pull Request 101 from github into your local sessionpr_finish(101)
: After you've merged your PR on github, deletes the branch locally and remotely, makes sure you are back on main branchSometimes it feels like you'll be doing a lot of waiting
Push...wait 23 minutes for it to finish building on Windows
Sometimes it feels like you'll be doing a lot of waiting
Push...wait 23 minutes for it to finish building on Windows
Push...google some obscure error message
Sometimes it feels like you'll be doing a lot of waiting
Push...wait 23 minutes for it to finish building on Windows
Push...google some obscure error message
Realise you have specified shell: RScript {0}
instead of shell: Rscript {0}
(there is an upper case S
in the first one. Thank you Jim Hester for finding this)
Sometimes it feels like you'll be doing a lot of waiting
Push...wait 23 minutes for it to finish building on Windows
Push...google some obscure error message
Realise you have specified shell: RScript {0}
instead of shell: Rscript {0}
(there is an upper case S
in the first one. Thank you Jim Hester for finding this)
Realise you have spent several days debugging some issue with GH actions that was actually just some missing {
I feel like I spent 90% of last year trying to get GH actions passing
I really wish I had learnt a bit about it before blindly pushing changes - e.g., that you can run actions locally
I feel like I spent 90% of last year trying to get GH actions passing
I really wish I had learnt a bit about it before blindly pushing changes - e.g., that you can run actions locally
Some sample commit messages:
"Try windows old-rel instead of 3.6"
If your tests fail, does your software actually work?
A single test failure doesn't mean it is broken!
If your tests fail, does your software actually work?
A single test failure doesn't mean it is broken!
greta
stay in a place of "it isn't any more broken than before..."
If your tests fail, does your software actually work?
A single test failure doesn't mean it is broken!
greta
stay in a place of "it isn't any more broken than before..."
Slightly brain melting: trying to diff error messages and mentally regression test them. Not what it is designed for.
If your tests fail, does your software actually work?
A single test failure doesn't mean it is broken!
greta
stay in a place of "it isn't any more broken than before..."
Slightly brain melting: trying to diff error messages and mentally regression test them. Not what it is designed for.
Waiting 1-24 minutes for a build to finish can be a massive time suck.
reprex
dist_type <- "normal"n_dim <- 6paste0("Following a ", dist_type, " distribution with ", n_dim, " dimensions")
## [1] "Following a normal distribution with 6 dimensions"
dist_type <- "normal"n_dim <- 6paste0("Following a ", dist_type, " distribution with ", n_dim, " dimensions")
## [1] "Following a normal distribution with 6 dimensions"
glue("Following a {dist_type} distribution with {n_dim} dimensions")
## Following a normal distribution with 6 dimensions
See my blog post, "glue magic Part 1"
print_file_msg_paste <- function(n_file){ msg <- ifelse(test = n_file == 1, yes = paste0("Found ", n_file, " file"), no = paste0("Found ", n_file, " files")) cat(msg)}
print_file_msg_paste(0)
## Found 0 files
print_file_msg_paste(1)
## Found 1 file
print_file_msg_paste(2)
## Found 2 files
print_file_msg_cli <- function(n_file){ cat(format_message("Found {n_file} file{?s}"))}
print_file_msg_cli(1)
## Found 1 file
print_file_msg_cli(2)
## Found 2 files
print_file_msg_cli(3)
## Found 3 files
In the past 12 months:
End.
greta
softwareKeyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |