Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to execute this gist, run the line bellow in terminal | |
\curl -L https://raw.github.com/gist/af96b42f98cc6cbb777d0634a6677a22/install_source_code_pro.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t11_raw = readxl::read_excel("nat-chil-meas-prog-eng-2020-2021-tab.xlsx", sheet = "Table 11", skip = 13) | |
t11 = t11_raw %>% | |
janitor::clean_names() | |
# names(t11) | |
names(t11)[1:2] = c("class", "year") | |
t11_most_deprived = t11 %>% | |
select(class, year, prevalence_3) %>% | |
fill(class) %>% | |
filter(str_detect(string = class, pattern = "Reception|Year")) %>% | |
slice(-c(1:2)) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Presentation Ninja" | |
subtitle: "⚔<br/>with xaringan" | |
author: "Yihui Xie" | |
institute: "RStudio, PBC" | |
date: "2016/12/12 (updated: `r Sys.Date()`)" | |
output: | |
xaringan::moon_reader: | |
lib_dir: libs | |
nature: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remotes::install_cran("questionr") | |
#> Skipping install of 'questionr' from a cran remote, the SHA1 (0.7.0) has not changed since last install. | |
#> Use `force = TRUE` to force installation | |
library(questionr) | |
d = data.frame(name = c("robin", "milena"), favourite_drink = c("coffee", "tea")) | |
lookfor(data = d, "drink") | |
#> variable | |
#> 2 favourite_drink | |
# <sup>Created on 2019-03-07 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)</sup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url_csv = "https://github.com/d3/d3-plugins/raw/master/graph/data/cities.csv" | |
# read-in non-spatial table: | |
c = readr::read_csv(url_csv) | |
# convert to spatial: | |
cs1 = sf::st_as_sf(c, coords = c("longitude", "latitude")) | |
download.file(url = url_csv, destfile = "cities.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
age4 <- c(346,81,435) | |
age5_19 <- c(580,420,1730) | |
age20_34 <- c(726,354,1321) | |
age35_64 <- c(1296,823,2567) | |
age65 <- c(2028,1112,2883) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Aim: take a matrix representing a convex polygon, return its centroid, | |
# demonstrate how algorithms work | |
# Pre-requisite: an input object named poly_mat with 2 columns representing | |
# vertices of a polygon, with 1st and last rows identical | |
# Step 1: create sub-triangles, set-up ------------------------------------ | |
O = poly_mat[1, ] # create a point representing the origin | |
i = 2:(nrow(poly_mat) - 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` r | |
pkgs = c("stringr", "emojifont") | |
if(any(!pkgs %in% installed.packages())) { | |
install.packages(pkgs) | |
} | |
story_original = "🍞🍻🐢😱🏥😷💊➡🥛☕💪🍅🚲🍻" | |
# something funny with 9th char | |
char_broken = stringr::str_sub(story_original, start = 9, end = 9) | |
emojifont::search_emoji("bottle") | |
#> [1] "baby_bottle" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` r | |
library(future) | |
plan(multiprocess) | |
devtools::install_github("r-rust/gifski") | |
#> Using GitHub PAT from envvar GITHUB_PAT | |
#> Skipping install of 'gifski' from a github remote, the SHA1 (6f921380) has not changed since last install. | |
#> Use `force = TRUE` to force installation | |
system("pip3 install youtube-dl") | |
system("youtube-dl https://youtu.be/CzxeJlgePV4 -o v.mp4") | |
system("ffmpeg -i v.mp4 -t 00:00:03 -c copy out.mp4") |
NewerOlder