Skip to content

Instantly share code, notes, and snippets.

View dylanpieper's full-sized avatar

Dylan Pieper dylanpieper

View GitHub Profile
@dylanpieper
dylanpieper / ellmer-commits.R
Created April 6, 2025 17:44
Classify and visualize {ellmer} git commits
library(gh)
library(dplyr)
library(hellmer)
library(ggplot2)
library(gganimate)
library(dplyr)
library(tibble)
library(lubridate)
library(scales)
library(cli)
@dylanpieper
dylanpieper / batching-benchmark.R
Last active March 8, 2025 21:19
Benchmark for Batching LLMs in R
library(hellmer)
library(tidyllm)
library(ellmer)
library(purrr)
library(tictoc)
library(dplyr)
library(tidyr)
library(ggplot2)
library(patchwork)
library(RColorBrewer)
@dylanpieper
dylanpieper / survey.R
Last active March 2, 2025 19:14
Example survey with expressions and text piping
survey <- list(
title = "R Package Feedback",
pages = list(
list(
name = "ratings_page",
elements = list(
list(
type = "matrix",
name = "rating",
title = "Please rate the shinysurveyjs 📦:",
@dylanpieper
dylanpieper / roxynorm-prefix.md
Last active March 2, 2025 19:15
Pal prompt for roxygen normalization

Roxygen Normalization

You are a terse assistant designed to help R users write roxygen documentation according to CRAN and tidy style with a consistent format. Respond with only the needed R code, no backticks or newlines around the response. Intersperse newlines within function calls as needed, per tidy style.

As example, given the input:

#' app
#'
#' this makes an app
@dylanpieper
dylanpieper / app.R
Last active November 29, 2024 02:32
Compare Sequential and Parallel Chats Using Elmer
library(shiny)
library(furrr)
library(elmer)
library(text2vec)
library(tm)
library(bslib)
library(waiter)
# Set your API keys upfront
Sys.setenv(OPENAI_API_KEY = "")
@dylanpieper
dylanpieper / build_themes.R
Last active February 18, 2023 19:46
Identify themes within list elements, then build common themes across list elements
library(openai)
library(tidyverse)
identify_themes <- function(raw_text, summary_length = 1000, number_of_themes){
response <- create_completion(
model = "text-davinci-003",
max_tokens = summary_length,
prompt = paste("Find the", number_of_themes, "most common themes in the following text:", raw_text)
)
@dylanpieper
dylanpieper / lat_lng_to_fips.txt
Last active July 15, 2022 22:03
Convert latitude and longitude to county fips code and create a leaflet map
# Convert latitude and longitude to county FIPS code from a survey and create a leaflet map
# Load your survey and define the lat/long variables as numeric
survey <- tibble::tribble(
~Latitude, ~Longitude, ~Name,
44.617000, -92.556600, "<b>Hagar City, WI</b> </br> Trenton Bluff Prairie </br> Ridge Soaring </br> S to SW </br> P2",
43.256443, -89.789153, "<b>Sauk City, WI</b> </br> Towing </br> E or W </br> P2",
43.036036, -89.502803, "<b>Madison, WI</b> </br> Elver Park </br> Training Hill </br> NNE to NNW </br> P1",
44.9369, -91.3929, "<b>Chippewa Falls, WI</b> </br> Home"
)