This file contains hidden or 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
library(tidyverse) | |
library(hkdatasets) | |
hk_accidents %>% glimpse() | |
## These charts look ridiculous but at least the jitter points are aligned with the text | |
hk_accidents %>% | |
filter(Year == 2017) %>% | |
ggplot(aes(x = Natural_Light , y = No__of_Vehicles_Involved)) + |
This file contains hidden or 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
# Whole word matching | |
grepl("\\<apple\\>", "pineapple", ignore.case = TRUE) # No match | |
grepl("apple", "pineapple", ignore.case = TRUE) # Match |
This file contains hidden or 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
aws polly synthesize-speech ^ | |
--output-format mp3 ^ | |
--voice-id Joanna ^ | |
--text "Whose woods these are I think I know. His house is in the village though; He will not see me stopping here To watch his woods fill up with snow. My little horse must think it queer To stop without a farmhouse near Between the woods and frozen lake The darkest evening of the year. He gives his harness bells a shake To ask if there is some mistake. The only other sound’s the sweep Of easy wind and downy flake. The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep." ^ | |
robertfrost.mp3 |
This file contains hidden or 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
# Just convert | |
ffmpeg -ss 0 -i test.mp4 -f gif output.gif | |
# Double speed | |
ffmpeg -ss 0 -i test.mp4 -filter:v "setpts=0.5*PTS" -f gif output.gif | |
# Quadruple speed | |
ffmpeg -ss 0 -i test.mp4 -filter:v "setpts=0.25*PTS" -f gif output.gif |
This file contains hidden or 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
library(tidyverse) | |
library(googlesheets4) | |
sheet_url <- "https://docs.google.com/spreadsheets/d/1usk9Q-5lA4bL_z6KXpUohc_2x_KhDgLxtm-YEtim_yk/" | |
# define google sheets ---------------------------------------------------- | |
## may consider using purrr once we get to more sheets | |
data_master_cnw <- googlesheets4::read_sheet(ss = sheet_url, sheet = "Central & Western") | |
data_master_wanchai <- googlesheets4::read_sheet(ss = sheet_url, sheet = "Wan Chai") |
This file contains hidden or 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
#### Assigning objects in a list to Global Environment #### | |
## 1. Put data frames into a named list | |
p_list <- | |
list("data1" = iris, | |
"data2" = mtcars, | |
"data3" = mtcars) | |
## 2. Extract the names and save into an object | |
p_list_names <- names(p_list) |
This file contains hidden or 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
#' Run a summary of functions and the associated description | |
#' for a loaded package | |
#' | |
#' @param package_name String providing the name of the loaded package, e.g. surveytoolbox | |
#' | |
#' @examples | |
#' \dontrun{ | |
#' pkg_summary("surveytoolbox") | |
#' pkg_summary("wpa") | |
#' pkg_summary("rwa") |
This file contains hidden or 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
## This is a minimal example to show how you can create a | |
## function that generates HTML reports using RMarkdown. | |
## | |
## This uses a list-pmap workflow so you can input lists | |
## as arguments and dynamically produce a RMarkdown that | |
## is only limited by the length of your lists. | |
## | |
## The example below outputs a table and two plots from | |
## `iris`. |
This file contains hidden or 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
library(tidyverse) | |
library(networkD3) | |
## Nodes data frame describing all the nodes in the network | |
## The first entry in nodes dataframe is node 0, the next entry is node 1 and so on. | |
## The nodes dataframe must be sorted according to this sequence. | |
## This is the only way to tie the nodes dataframe to the links dataframe. | |
TestNodes <- data.frame(name = c("Alpha", | |
"Beta", | |
"Cat", |
This file contains hidden or 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
paste(rep("l", exp(10)), collapse = "o") |