Skip to content

Instantly share code, notes, and snippets.

View laderast's full-sized avatar

Ted Laderas laderast

View GitHub Profile
@laderast
laderast / week2_solution.R
Created February 20, 2024 16:33
Week 2 Solutions
library(dplyr)
library(ggplot2)
covid <- readr::read_csv("data/covid.csv")
# One solution (the one that everyone does)
covid_ny <- covid |>
filter(state=="NY")
ggplot(covid_ny, aes(x=date, y=cases)) +
---
title: "SummaryTable"
format: html
---
```{r}
library(palmerpenguins)
data(penguins)
ojs_define(penguins)
@laderast
laderast / mascot_count.csv
Last active February 13, 2024 21:57
Parse List of Cereal Mascots to CSV
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 20 columns, instead of 16. in line 9.
"","name","manufacturer","type","calories","protein","fat","sodium_mg","fiber_content_g","carbo_g","sugars_g","potass","vitamins","shelf","weight","cups","rating","X","mascot","has_mascot"
"1","100% Bran","Nabisco","C",70,4,1,130,10,5,6,280,25,"3",1,0.33,68.402973,NA,NA,"No"
"2","100% Natural Bran","Quaker Oats","C",120,3,5,15,2,8,8,135,0,"3",1,1,33.983679,NA,NA,"No"
"3","All-Bran","Kelloggs","C",70,4,1,260,9,7,5,320,25,"3",1,0.33,59.425505,NA,NA,"No"
"4","All-Bran with Extra Fiber","Kelloggs","C",50,4,0,140,14,8,0,330,25,"3",1,0.5,93.704912,NA,NA,"No"
"5","Almond Delight","Ralston Purina","C",110,2,2,200,1,14,8,-1,25,"3",1,0.75,34.384843,NA,NA,"No"
"6","Apple Cinnamon Cheerios","General Mills","C",110,2,2,180,1.5,10.5,10,70,25,"1",1,0.75,29.509541,NA,NA,"No"
"7","Apple Jacks","Kelloggs","C",110,2,0,125,1,11,14,30,25,"2",1,1,33.174094,NA,NA,"No"
"8","Basic 4","General Mills","C",130,3,2,210,2,18,8,100,25,"3",1.33,0.75,37.038562,NA,NA,"No"
"9","Bran Chex","Ralston Purina","C",90,2,1,200,4,15,6,125,25,"1",1,0.6
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 7.
"","title","site","country","year_release","box_office","director","number_of_subjects","subject","type_of_subject","race_known","subject_race","person_of_color","subject_sex","lead_actor_actress"
"1","10 Rillington Place","tt0066730","UK",1971,NA,"Richard Fleischer",1,"John Christie","Criminal","Unknown",NA,FALSE,"Male","Richard Attenborough"
"2","12 Years a Slave","tt2024544","US/UK",2013,56700000,"Steve McQueen",1,"Solomon Northup","Other","Known","African American",TRUE,"Male","Chiwetel Ejiofor"
"3","127 Hours","tt1542344","US/UK",2010,18300000,"Danny Boyle",1,"Aron Ralston","Athlete","Unknown",NA,FALSE,"Male","James Franco"
"4","1987","tt2833074","Canada",2014,NA,"Ricardo Trogi",1,"Ricardo Trogi","Other","Known","White",FALSE,"Male","Jean-Carl Boucher"
"5","20 Dates","tt0138987","US",1998,537000,"Myles Berkowitz",1,"Myles Berkowitz","Other","Unknown",NA,FALSE,"Male","Myles Berkowitz"
"6","21","tt0478087","US",2008,81200000,"Robert Luketic",1,"Jeff Ma","Other","Known","Asian American",TRUE,"Male","Jim Stu
@laderast
laderast / js_reactable_example.qmd
Created August 3, 2023 17:50
Test of JS/Reactable Functionality
---
title: "testing"
format: html
editor: visual
---
## Quarto
This is a test of interacting with a reactable with selectable rows. We use the `{reactable}` htmlwidget and add an extra JavaScript Button to copy the selected field titles to the clipboard as an R-formatted vector.
---
title: "pmap"
author: "Ted Laderas"
date: "February 28, 2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@laderast
laderast / app.R
Last active December 14, 2021 12:05
Tidyeval/Shiny example 2: passing multiple inputs using syms()
# Shiny App showing tidyeval with multiple variables
library(shiny)
data(iris)
library(dplyr)
numericVariables <- c("Sepal.Length", "Sepal.Width","Petal.Length", "Petal.Width")
# Define UI for application that draws a histogram
ui <- fluidPage(
@laderast
laderast / app.R
Created August 7, 2018 21:59
Using Tidyeval with Shiny - selectInput
# Code example to show how to use tidyeval within Shiny
library(shiny)
data(iris)
library(dplyr)
numericVariables <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
ui <- fluidPage(
@laderast
laderast / app.R
Last active July 12, 2018 17:58
minimal reproducible app for selectorId fix
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
@laderast
laderast / expressionSetManipulation.R
Last active February 7, 2019 23:09
Ways to manipulate Expression Sets for HW3
# Some useful ways to manipulate expressionSets
# Please cite me if you use this code
library(Hiiragi2013)
# load data
data(x)
# Show sample Information
pData(phenoData(x))