Skip to content

Instantly share code, notes, and snippets.

@edavidaja
edavidaja / r-fit-text.qmd
Created December 11, 2023 18:56
fit-text
---
format: revealjs
---
## purrr
::: r-fit-text
`map(.x, .f, ...)`
:::
@edavidaja
edavidaja / migrate-libraries.sh
Last active June 9, 2023 16:15
a script for users to run that migrates their package libraries on Workbench
#!/bin/bash
set -e
BCYAN='\033[1;36m'
BRED='\033[1;31m'
NC='\033[0m' # No Color
BOLD='\033[1m'
print_heading() {
echo ""
#!/usr/bin/Rscript
get_nodes <- function(nodes = Sys.getenv("RSTUDIO_NODES")) {
unlist(strsplit(nodes, ",", fixed = TRUE))
}
get_health_check <- function(node_address) {
con <- url(sprintf("http://%s/health-check", node_address))
on.exit(close(con))
readLines(con)
@edavidaja
edavidaja / app.R
Created March 24, 2021 19:35
shiny + the clipboard api
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("clippers"),
sidebarLayout(
sidebarPanel(
textAreaInput("text_input", "enter text:"),
# using submit button makes the copy less of a lie (but still a lie) because
@edavidaja
edavidaja / app.R
Created February 19, 2021 17:08 — forked from edgararuiz-zz/app.R
library(shinydashboard)
library(dplyr)
library(dbplyr)
library(purrr)
library(shiny)
library(highcharter)
library(DT)
library(htmltools)
# Use the `config` package to get the credentials
# renv must be active
install.packages(
c(
"jimhester/lookup",
"devtools",
"usethis",
"MilesMcBain/breakerofchains"
)
)
@edavidaja
edavidaja / ggrepel-directlabels.md
Created March 6, 2020 04:27
direct labels with {ggrepel}

{directlabels} lets you attach categorical labels to many plots. for labeling values on plots, use ggrepel:

suppressPackageStartupMessages({
  library(ggplot2)
  library(ggrepel)
  library(dplyr)
})
library(ggplot2)
library(purrr)
split_iris <- split(iris, 1:3)
map2(
  split_iris, names(split_iris), ~ {
    lm(Sepal.Length ~ Sepal.Width, data = .x)
    p <- ggplot(.x, aes(Sepal.Width, Sepal.Length, color = Species)) + geom_point()
    print(p)
 ggsave(plot = p, filename = paste0("plot_", .y, ".png"))
@edavidaja
edavidaja / categorical-legends.md
Created February 25, 2020 23:38
categorical legends with ggtext
library(ggplot2)
library(ggtext)
 
dat <- economics_long[economics_long$variable %in% c("psavert", "uempmed"), ]
ggplot(dat, aes(date, value, color = variable)) +
  geom_line() +
  scale_color_manual(values = c("#0072B2", "#009E73")) +
 labs(
@edavidaja
edavidaja / nord-windows-terminal
Created October 26, 2019 17:29
Nord colors for Windows Terminal
{
"background": "#2E3440",
"black" : "#3B4252",
"blue" : "#81A1C1",
"cyan" : "#88C0D0",
"foreground": "#D8DEE9",
"green" : "#A3BE8C",
"brightBlack" : "#4C566A",
"brightBlue" : "#81A1C1",
"brightCyan" : "#8FBCBB",