Skip to content

Instantly share code, notes, and snippets.

View mine-cetinkaya-rundel's full-sized avatar

Mine Cetinkaya-Rundel mine-cetinkaya-rundel

View GitHub Profile
# Remake of plot from https://www.kdnuggets.com/data-science-salaries-job-market-analysis-2024-2025
# load packages
library(tidyverse)
library(scales)
# create data frame
ds_salaries <- tribble(
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / claude-recode-membership.md
Last active January 22, 2025 03:10
Claude - Recoding membership status in R - 2025-01-21

Another variable that needs some cleaning up is membership_status. Currently it should either be NA or contain some text that says "Select ... to register for this group". Recode this variable to say "Closed" if the current value is NA or "Open" otherwise. Save the resulting dataset with this new variables as clubs, i.e., overwrite the original data frame. Then, display the first 10 rows of the dataset, moving membership_status to the beginning of the dataset to make sure it appears in the output in your rendered document.

I'll help you clean up the membership_status variable. Let's break this down into steps:

# Recode membership_status to "Closed" if NA, "Open" otherwise
clubs$membership_status <- ifelse(is.na(clubs$membership_status), "Closed", "Open")

# Reorder columns to put membership_status first
clubs &lt;- clubs[, c("membership_status", setdiff(names(clubs), "membership_status"))]
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / code-highlighting-example.qmd
Last active October 1, 2023 14:50
Potential solutions for https://elk.zone/fosstodon.org/@3mma@mastodon.social/111159483378645767
---
format: revealjs
execute:
echo: true
engine: knitr
---
# Option 1: `code-line-numbers`
## RStudio Projects
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / multiple-chunks-highlight-revealjs.qmd
Created November 20, 2022 20:39
Highlighting across multiple code chunks in a Quarto revealjs presentation
---
format:
revealjs:
highlight-style: a11y-dark
execute:
echo: true
---
```{r}
#| code-line-numbers: "|1|2"
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / tidypumpkin.R
Last active August 27, 2023 20:50
Code developed during the "Break it, fix it, trash it, change it, plot, update it" webinar
# Find on RStudio Cloud: https://bit.ly/tidypumpkin
# inspirations -----------------------------------------------------------------
# https://twitter.com/alyssastweeting/status/1450270826347913220
# https://twitter.com/Emma_McHuge/status/1450434288319537162
# load packages ----------------------------------------------------------------
library(tidyverse)
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / lms-bs.R
Last active November 13, 2020 15:24
Merging assignment scores into a format your LMS requires
library(tidyverse)
lms_export <- tribble(
~Name, ~`Student ID`, ~`HW 01 [Total Pts: 100 Score] |so many more characters`, ~`and many more columns`,
"Dorianne Grey", 12345, NA, NA,
"Krista Rose", 67890, NA, NA
)
hw_scores <- tribble(
~student_id, ~score,
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / learnr-dark.css
Created October 26, 2020 10:16
Sample (in no way perfect!) CSS for learnr tutorials with dark background
body {
font-size: 16px;
}
.topicsList .topic {
font-size: 18px;
}
p.caption {
font-size: 0.6em;
}
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / the-one-with-the-most-words.R
Created September 5, 2020 22:50
The one with the most words
# Load packages ----------------------------------------------------------------
library(tidytext)
library(friends)
library(tidyverse)
# The six friends --------------------------------------------------------------
six_friends <- c("Phoebe Buffay", "Chandler Bing", "Rachel Green", "Monica Geller", "Joey Tribbiani", "Ross Geller")
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / you-guys.R
Created August 31, 2020 13:51
Number of utterances of "you guys" from the Friends cast
library(friends) # devtools::install_github("EmilHvitfeldt/friends")
library(tidyverse)
you_guys <- friends %>%
mutate(text = tolower(text)) %>%
filter(str_detect(text, "you guys")) %>%
count(speaker, sort = TRUE)
you_guys
#> # A tibble: 70 x 2
---
output: learnr::tutorial
runtime: shiny_prerendered
---
```{r setup, include=FALSE}
library(learnr)
```
## Exercise with Hint