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
# Regular R CMD check | |
devtools::check() | |
# Check R-hub | |
devtools::check_rhub() | |
# Cross-platform R CRAN check | |
rhub::check_for_cran() | |
# Return a character vector with the names of dependencies - CRAN only |
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
## Date expansion | |
validweeks <- | |
unique(clean_wbq_totalview$Date) %>% | |
purrr::map(function(x){ | |
seq(x, x + 6, by = "days") | |
}) %>% | |
purrr::reduce(c) |
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
import_to_fst <- function(path){ | |
temp_df <- import_wpa(path) | |
path_fst <- gsub(pattern = "csv$", | |
replacement = "fst", | |
x = path) | |
fst::write_fst(temp_df, path_fst) | |
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
library(tidyverse) | |
10:30 %>% | |
map(function(x){ | |
prob_v <- | |
c(x, | |
100 - 2*x, | |
100 - x - (100 - 2*x)) | |
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
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 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 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 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 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 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) |