Excited and grateful that R-Universe is R Consortium's newest top-level project! This means sustained support for @rOpenSci.hachyderm.io.ap.brid.gy's platform for discovery and publishing of #rstats packages. Hats off to @jeroenooms.bsky.social for his leadership!
ropensci.org/blog/2024/12...
Posts by Anna Krystalli
Screenshot of the following R code library(dplyr) library(aocodeR) input <- aoc_get_input( day = 4, year = 2024, cookie_path = ".cookie.txt" ) |> readr::read_fwf() n_cols <- nchar(input[1, "X1", drop = TRUE]) cols <- seq(n_cols) colnames <- paste0("X", seq(n_cols)) tbl <- input |> tidyr::separate(X1, colnames, sep = cols, remove = TRUE) |> as.matrix() # Part 1 ---- detect_xmas <- function(tbl, loc, dir = c(1L, 0L)) { idx <- data.frame( row = loc[1] + seq(3L) * dir[1], col = loc[2] + seq(3L) * dir[2] ) |> as.matrix() x <- try(head(tbl[idx], 3L), silent = TRUE) if (inherits(x, "try-error") || length(x) != 3L) { return(FALSE) } isTRUE(all.equal(c("X", x), c("X", "M", "A", "S"))) } locs <- which(tbl == "X", arr.ind = TRUE) locs <- split(locs, row(locs)) purrr::map(locs, ~ { loc <- .x dirs <- list( c(1, 0), c(0, 1), c(-1, 0), c(0, -1), c(1, 1), c(-1, -1), c(1, -1), c(-1, 1) ) purrr::map_lgl( dirs, ~ detect_xmas(tbl, loc = loc, dir = .x) ) }) |> unlist() |> sum() ## PART 2 ---- detect_x_mas <- function(tbl, loc = loc) { rows <- loc[1] + c(-1, 1) cols <- loc[2] + c(-1, 1) grid <- try( tbl[ seq(rows[1], rows[2]), seq(cols[1], cols[2]) ], silent = TRUE ) if (inherits(grid, "try-error") || any(dim(grid) != c(3, 3))) { return(FALSE) } all( setequal(grid[c(1, 9)], c("M", "S")), setequal(grid[c(3, 7)], c("M", "S")) ) } locs <- which(tbl == "A", arr.ind = TRUE) locs <- split(locs, row(locs)) purrr::map_lgl( locs, ~ detect_x_mas(tbl, loc = .x) ) |> sum()
Screenshot of the following R code: library(aocodeR) # -- Process input ---- input <- aoc_get_input( day = 5, year = 2024, cookie_path = ".cookie.txt" ) |> readr::read_lines() updates <- input[stringr::str_detect(input, ",")] |> strsplit(split = ",") |> purrr::map(~ as.integer(.x)) rules <- input[stringr::str_detect(input, "\\|")] |> strsplit(split = "\\|") |> purrr::map(~ as.integer(.x)) # PART 1 ---- ## -- Functions ---- get_later_pages <- function(page, rules) { is_page_rule <- purrr::map_lgl(rules, ~ .x[1] == page) rules[is_page_rule] |> purrr::map_int(~ .x[2]) } mem_get_later_pages <- memoise::memoise(get_later_pages) check_page <- function(i, update, rules) { page <- update[i] later_pages <- mem_get_later_pages(page, rules) !any(update[seq(i - 1)] %in% later_pages) } check_update <- function(update, rules) { for (i in seq_along(update)[-1]) { if (!check_page(i, update, rules)) { return(FALSE) } } TRUE } get_middle <- function(x) { x[length(x) %/% 2 + 1] } ## -- workflow ---- valid_updates <- purrr::map_lgl(updates, ~ check_update(.x, rules)) updates[valid_updates] |> purrr::map_int(get_middle) |> sum() # Part 2 ---- # Functions get_earlier_pages <- function(page, rules) { is_page_rule <- purrr::map_lgl(rules, ~ .x[2] == page) rules[is_page_rule] |> purrr::map_int(~ .x[1]) } mem_get_earlier_pages <- memoise::memoise(get_earlier_pages) reorder_update <- function(update) { idx <- purrr::map_int( seq_along(update), ~ page_idx(.x, update, rules) ) |> order() update[idx] } page_idx <- function(i, update, rules) { sum(update[-i] %in% mem_get_earlier_pages(update[i], rules)) + 1 } # Workflow invalid_updates <- updates[!valid_updates] purrr::map(invalid_updates, reorder_update) |> purrr::map_int(get_middle) |> sum()
Managed to spend some time catching up with
#AdventOfCode
(days 4 & 5) in
#rstats
...longer than I hoped on day 5 but satisfied to finally crack it!
aocoder 📦 for importing puzzles into R can be found here: github.com/annakrystall...
New paper published
E. Nyenah, P. Döll, @danielskatz.bsky.social, and @reinecke.bsky.social, "Software sustainability of global impact models," Geoscientific Model Development, v.17(23), pp. 8593–8611, 2024. doi.org/10.5194/gmd-...
In R, set `options(shiny.devmode = TRUE)` in your .Rprofile or call `shiny::devmode(TRUE)`. In Python, use `shiny run` with the `--dev-mode` flag.
Did you know #Shiny has a developer mode that turns on auto-reloading, an in-app error console and more? #RStats
Gingerbread house
My favourite Xmas tradition and recipe passed down by my American mom is making gingerbread houses!
It's sth I now do with my fiancee's niece, nephew and their cousins...we made 5 this year!! Sure it would warm mom's heart to know ♥️
“We don’t value software, data, and methods in the same way we value papers, even though those resources empower millions of scientists” 💯
www.statnews.com/sponsor/2024...
🎉 The {messy} package is now available on CRAN! 🎉
Read the introductory blog post here: nrennie.rbind.io/blog/introdu...
#RStats #StatsEd #DataScience
If you're interested in trying out LLMs in #rstats but don't know where to begin, I've added a few two vignettes to elmer: elmer.tidyverse.org/articles/elm... and elmer.tidyverse.org/articles/pro...
Dani bay
After being battered by high winds for the last 3 weeks, a calm morning has finally dawned!
Same!
Need help with regular expressions in R? Check out the RegExplain RStudio add-in by @grrrck.xyz
www.garrickadenbuie.com/project/rege...
#RStats #RegExp #RegEx #RStudio
😍😎
I'm an #rstats RSE too! And eager to connect with others on here too.
Thanks for this list BTW! It made it much easier to find folks quickly
I would love love love to connect to more Research Software Engineers!
This is quite #rstats heavy currently, but is open to all of any level!
go.bsky.app/4kfWypW