Skip to content

Instantly share code, notes, and snippets.

View mccarthy-m-g's full-sized avatar

Michael McCarthy mccarthy-m-g

View GitHub Profile

Question

Dear #rstats community, I have a problem. I have a df with multiple char columns which I want to coerce to factors and a list of pre-defined factor level orders (vectors) that I want to apply in the process. Now apparently this isn't a wide-spread thing to do. I am using #tidyverse code.

My approach of

df <- df |> mutate(across(all_of(charvars), ~factor(., levels= levellist[[which(factors==cur_column())]]))

throws me an error telling me it "cant compute the first column ("who")" followed by "internal error"...backtrace attached. My problem is: I used the same approach literally 3 lines above on different subsets before and it works!

@mccarthy-m-g
mccarthy-m-g / callout-mastodon.css
Last active May 15, 2023 22:05
Embed Mastodon posts in Quarto documents
.callout-mastodon {
border-left-color: #6364ff !important;
}
.callout-header {
border-bottom: none;
font-size: .9rem;
font-weight: 600;
opacity: 75%;
}

Question

Okay folks how alive is the #rstats #dataviz crowd here? I want to create ridgeline plots with ggridges::geom_density_ridges, but with the trim=T option of ggplot::geom_density. There's an open feature request at wilkelab/ggridges#57 so I don't think @clauswilke has been able to implement this

Interested in ideas! Main reason to want ridges instead of vanilla density plots is multifaceted data — see example plot.

https://scholar.social/@dingemansemark/109659218719054960

Code

@mccarthy-m-g
mccarthy-m-g / 2022-11-29_str-split.md
Last active November 29, 2022 21:42
Using `stringr::str_split()` with dplyr to extract and combine strings