Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jbkunst/jbkmisc
No description or website will be provided. A collection of raw shortcuts for my daily lies.
https://github.com/jbkunst/jbkmisc
mineonlymine miscellaneous package r
Last synced: about 1 month ago
JSON representation
No description or website will be provided. A collection of raw shortcuts for my daily lies.
- Host: GitHub
- URL: https://github.com/jbkunst/jbkmisc
- Owner: jbkunst
- License: other
- Created: 2016-03-15T13:09:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-11-05T14:27:49.000Z (about 5 years ago)
- Last Synced: 2024-10-11T19:13:49.237Z (2 months ago)
- Topics: mineonlymine, miscellaneous, package, r
- Language: R
- Homepage:
- Size: 1.31 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - jbkunst/jbkmisc - No description or website will be provided. A collection of raw shortcuts for my daily lies. (R)
README
---
title: "jbkmisc"
output:
github_document:
toc: true
editor_options:
chunk_output_type: console
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
library(jbkmisc)
library(printr)
library(lubridate)
```## Why? What?
Idk:
- Just things I need sometimes.
- Just helpers and wrappers for my __laziness__.## Installation
```
source("https://install-github.me/jbkunst/jbkmisc")
```## Date helpers
### `ym_to_date`
```{r}
ym_to_date(ym = c(200902, 201912), day = 1)
```### `ym_diff`
```{r}
ym_diff(ym = c(200902, 201912), ym2 = c(200901, 201712))
```### `ym_add_months`
```{r}
ym_add_months(c(200902, 201912), months = c(1, -12))
```### `ym_format`
```{r}
ym_format(c(200902, 201912), "%B del %Y")
```### `ym_div`
```{r}
year <- format(ymd(20170101) + months(0:11), "%Y%m")
yearym_div(year, ng = 3)
ym_div(year, ng = 4)
```## dplyr
### `countp`
```{r}
countp(mtcars, cyl)countp(mtcars, cyl, am)
library(dplyr)
mtcars %>%
group_by(cyl) %>%
countp(am)
```### `ccount`
```{r}
ccount(iris, Species)
```### `clean`
```{r}
head(iris, 3)clean(head(iris, 3))
```## dbplyr
### `dbRemoveTableIfExists`
```
dbRemoveTableIfExists(con, name)
```### `compute2`
```
compute2(con, name)
```## ggplot2
### `theme_jbk`
Based on `hrbrthemes::theme_ipsum`, soft gridline color, legend at top for more horizontal space.
```{r}
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.
## blog & presentations
### `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`
```{r}
ico("tv", "red")
R()
```## tictoc
```{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()
```## shiny
### `get_my_local_ip`
```{r}
get_my_local_ip()
```## Report Helpers
### `format_tbl`
```{r}
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)
```## Stringr
### `str_clean`
```{r}
string <- c("name.with...points", "or_Under___scores")
stringstr_clean(string)
str_clean(string, fun = toupper)
```## Workflow
### `wf_create_folders`
create `data`, `code` and `output` folder.