knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE) library(jbkmisc) library(printr) library(lubridate)
Idk:
source("https://install-github.me/jbkunst/jbkmisc")
ym_to_date
ym_to_date(ym = c(200902, 201912), day = 1)
ym_diff
ym_diff(ym = c(200902, 201912), ym2 = c(200901, 201712))
ym_add_months
ym_add_months(c(200902, 201912), months = c(1, -12))
ym_format
ym_format(c(200902, 201912), "%B del %Y")
ym_div
year <- format(ymd(20170101) + months(0:11), "%Y%m") year ym_div(year, ng = 3) ym_div(year, ng = 4)
countp
countp(mtcars, cyl) countp(mtcars, cyl, am) library(dplyr) mtcars %>% group_by(cyl) %>% countp(am)
ccount
ccount(iris, Species)
clean
head(iris, 3) clean(head(iris, 3))
dbRemoveTableIfExists
dbRemoveTableIfExists(con, name)
compute2
compute2(con, name)
theme_jbk
Based on hrbrthemes::theme_ipsum
, soft gridline color, legend at top for more horizontal space.
library(ggplot2) library(dplyr) data("diamonds") d <- diamonds %>% filter(color %in% c("E", "J", "H")) %>% filter(cut %in% c("Ideal", "Premium", "Very Good")) %>% sample_n(10000) theme_set(theme_jbk()) ggplot(d, aes(carat, price)) + geom_point(aes(color = clarity), size = 0.1) + scale_y_continuous(labels = scales::dollar) + scale_color_viridis_d() + facet_grid(cut ~ color, scales = "free") + labs( title = "This is a Title", subtutle = "This is a longer subtitle", caption = "A caption which nobody read but it looks important" )
ggsav
and filename_gen
Automatic generation file names given a pattern to save without worry about names :D.
spin_jekyll_post
My custom spin r file to md and move the widgets, etc.
blog_set_chunk
Set opt chunk with my preferences
giphy
Put a giphy image given the id.
ico
ico("tv", "red") R()
jbk_tictoc_clear() jbk_tic(msg = "Some sleep") Sys.sleep(2) jbk_toc() jbk_tic(msg = "Go to sleep again!") Sys.sleep(1) jbk_toc() jbk_tictoc_log()
get_my_local_ip
get_my_local_ip()
format_tbl
data <- data.frame( a_value.e = c(NA, runif(3)), `another.vAlue__here` = c(NA, runif(3)) * 10000 ) data format_tbl(data) format_tbl(data, digits = 0, NA_symbol = "***", fun_title = toupper)
str_clean
string <- c("name.with...points", "or_Under___scores") string str_clean(string) str_clean(string, fun = toupper)
wf_create_folders
create data
, code
and output
folder.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.