knitr::opts_chunk$set(collapse = TRUE, comment = "#>") set.seed(1234) ## load pkg library(tfse)
Various useful functions for working with data and writing functions
Install from CRAN
## from CRAN repo install.packages("tfse")
Install dev version from Github
## from github remotes::install_github("mkearney/tfse")
Rescale to standard (0-1) scale
## 0-1 scale rescale_standard(-2:2)
Rescale to normal (mean = 0; sd = 1) scale
## z scores rescale_normal(-2:2)
Rescale to arbitrary lower/upper bounds
## specify new scale bounds rescale_pointscale(-2:2, 1, 10)
Print out the APA-formatted citation for R packages.
## print out APA citation for {rtweet} apa_citation("rtweet")
Use box_code()
to add a header-like chunk to your clipboard–paste in script as desired.
## store text in clipboard box_code("EXAMPLE #1") ## the pasted output: ##----------------------------------------------------------------------------## ## EXAMPLE #1 ## ##----------------------------------------------------------------------------##
Get all regular expression matches (using easier looka-heads/look-behinds)
## some text x <- c("This *is* a test", "#this *was* a test", "This *will* be a test!", "This *has been* a test; it *is* great.") ## return text between asterisks, return as atomic vector regmatches_(x, "(?<=\\*)\\S[^*]+(?=\\*)", drop = TRUE)
Figure out the name of a Github repo for a given package
## repo name of devtools desc_gh_repo("devtools")
Convert a Github link to the raw URL version
## path to raw version of Github file github_raw("https://github.com/mkearney/driven-snow/blob/master/theme/driven-snow.rstheme")
View the help documentation
## view R help documentatoin help(package = "tfse")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.