Skip to content

Instantly share code, notes, and snippets.

View jnolis's full-sized avatar
💖

Jacqueline Nolis jnolis

💖
View GitHub Profile
@jnolis
jnolis / 3-legged-twitter-auth.R
Last active January 19, 2020 05:23
Do 3-legged Twitter authentication for rtweet
# _____ __ __
# |__ / / /__ ____ _____ ____ ____/ /
# /_ <______/ / _ \/ __ `/ __ `/ _ \/ __ /
# ___/ /_____/ / __/ /_/ / /_/ / __/ /_/ /
# /____/ /_/\___/\__, /\__, /\___/\__,_/
# /____//____/
# RTWEET + 3-LEGGED-AUTH DEMO
# This code demonstrates how to do 3-legged authentication for Twitter
# using the {rtweet} package. Based heavily on code from Michael Kearney and Calli Gross
@jnolis
jnolis / spread.R
Last active October 29, 2018 04:07
Example spread
library(tidyverse)
# here is a table that spreads the way you'd want (with two rows):
tribble(
~a, ~b, ~c,
"a", "x", 3,
"a", "y", 2,
"b", "x", 4,
"b", "y", 7
@jnolis
jnolis / Dockerfile
Last active October 9, 2018 22:56
Dockerfile for R Plumber project
# start from the rocker/r-ver:3.5.0 image
FROM rocker/r-ver:3.5.0
# install the linux libraries needed for plumber
RUN apt-get update -qq && apt-get install -y \
libssl-dev \
libcurl4-gnutls-dev
# install plumber
RUN R -e "install.packages('plumber')"
@jnolis
jnolis / app.R
Last active August 20, 2019 01:28
Code for the my-classroom Shiny app
library(shiny)
library(dplyr)
library(ggplot2)
library(babynames)
size <- 25
colors <- c("F" = "#DE94AF", "M" = "#6C939F", "X" = "#D4C62A")
ui <- fluidPage(
@jnolis
jnolis / gist:e23f00d752b47671c9f0feccd333e1d4
Last active April 27, 2018 18:17
A better generator for using Keras in R for word2vec
# the example code provided by RStudio to use R for word2vec has an error if you don't have enough data.
# This fixes the error by having the generator reset when it runs out
skipgrams_generator <- function(text, tokenizer, window_size, negative_samples) {
gen <- texts_to_sequences_generator(tokenizer, sample(text))
function() {
next_value <- generator_next(gen)
if(is.null(next_value)){ #if there isn't new text from the generator
gen <<- texts_to_sequences_generator(tokenizer, sample(text)) # remake the generator
next_value <- generator_next(gen)