Skip to content

Instantly share code, notes, and snippets.

@edavidaja
edavidaja / Dockerfile
Created November 15, 2018 14:40
A dockerfile to install spacyr
FROM rocker/rstudio
RUN sudo apt-get update && sudo apt-get install python3 bzip2 -y
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \
bash miniconda.sh -b -p /opt/miniconda
ENV PATH "$PATH:/opt/miniconda/bin"
RUN conda config --set always_yes yes --set changeps1 no
RUN conda update -q conda
# because of the occasional build timeout from installing spacyr from github I install

Keybase proof

I hereby claim:

  • I am edavidaja on github.
  • I am edavidaja (https://keybase.io/edavidaja) on keybase.
  • I have a public key ASDP-zZ510_P1p8hM282a0gxaDAwG74VcPscm3UDVa8A4wo

To claim this, I am signing this object:

@edavidaja
edavidaja / convert_to_xlsx.R
Created May 28, 2019 22:08
convert legacy xls files to xlsx files
library(purrr)
xls_to_xlsx <- function(file) {
if (fs::path_ext(file) != "xls") {
stop("file must have extension xls")
}
sheets <- readxl::excel_sheets(file)
insheets <- map(sheets, ~readxl::read_excel(file, .x, col_names = FALSE))
@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",
@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(
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 / 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)
})
# renv must be active
install.packages(
c(
"jimhester/lookup",
"devtools",
"usethis",
"MilesMcBain/breakerofchains"
)
)
@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
@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