Skip to content

Instantly share code, notes, and snippets.

View perlatex's full-sized avatar

wang minjie perlatex

  • sichuan normal universtiy
View GitHub Profile
@perlatex
perlatex / Valentine.R
Created February 14, 2019 13:58
create heart for valentine's day using ggplot2 and gganimate
library(ggplot2)
library(dplyr)
library(gganimate)
heartdf = tibble(
t = seq(0, 2*pi, pi/60),
x = 16*sin(t)^3,
y = 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t)
)
@perlatex
perlatex / Valentine.R
Created February 15, 2019 06:05
Valentine
# learn from https://rpubs.com/dgrtwo/valentine
library(ggplot2)
library(dplyr)
library(gganimate)
heartdf <- tibble(
t = seq(0, 2 * pi, pi / 60),
x = 16 * sin(t)^3,
y = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t)
)
@perlatex
perlatex / gganimate_cookbook.rmd
Created March 8, 2019 13:22 — forked from thomasp85/gganimate_cookbook.rmd
Code for gganimate talk RStudio::conf 2019
---
title: "gganimate cookbook code"
output:
html_document:
df_print: tibble
highlight: kate
css: gganimate_cookbook.css
---
```{r setup}
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {
library(tidyverse)
library(brms)
library(tidybayes)
library(gganimate)
library(magick)
tb <- tibble(
index = 1:15,
a = runif(n = 15, min = 0, max = 2),
b = rnorm(15, mean = 2 * a, sd = 1),
@perlatex
perlatex / decision_boundary.org
Created January 19, 2020 02:29 — forked from ryanholbrook/decision_boundary.org
R code for plotting and animating the decision boundaries

Classifiers

Introduction

Looking at the decision boundary a classifier generates can give us some geometric intuition about the decision rule a classifier uses and how this decision rule changes as the classifier is trained on more data.

Plotting Functions

read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv") %>%
gather(date, cases, 5:ncol(.)) %>%
mutate(date = as.Date(date, "%m/%d/%y")) %>%
group_by(country = `Country/Region`, date) %>%
summarise(cases = sum(cases)) %>%
filter(country != "Others" & country != "Mainland China") %>%
bind_rows(
tibble(country = "Republic of Korea", date = as.Date("2020-03-11"), cases = 7755)
) %>%
group_by(country) %>%
library(tidyverse)
# Download Fira Sans Condensed from
# https://fonts.google.com/specimen/Fira+Sans+Condensed
high_mean <- 12
high_sd <- 4
flat_mean <- 35
flat_sd <- 12
@perlatex
perlatex / celebration2020.Rmd
Created March 25, 2020 05:35 — forked from thomasp85/celebration2020.Rmd
Code and exercises for the celebRation2020 ggplot2 workshop
---
title: "ggplot2 examples and exercises"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
This document contains all the code that is displayed during the workshop. The
library(tidyverse)
library(scales)
library(broom)
library(gganimate)
# Original by David Robinson at http://varianceexplained.org/files/loess.html
# Basic static plot -------------------------------------------------------