Various useful functions for working with data and writing functions
Install from CRAN
Install dev version from Github
Rescale to standard (0-1) scale
Rescale to normal (mean = 0; sd = 1) scale
Rescale to arbitrary lower/upper bounds
Print out the APA-formatted citation for R packages.
## print out APA citation for {rtweet}
apa_citation("rtweet")
#> [32m↪[39m [38;5;244mAdding APA citation of {rtweet} to clipboard![39m
#> [1m[32mâś”[39m Ready to paste![22m
#>
#> Kearney, M. W. (2018). rtweet: Collecting twitter data (R package version
#> 0.6.7) [Computer software]. The Comprehensive R Archive Network. Available
#> from https://cran.r-project.org/package=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)
#> [1] "is" "was" "will" "has been" "is"
Figure out the name of a Github repo for a given package
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")
#> [1] "https://raw.githubusercontent.com/mkearney/driven-snow/master/theme/driven-snow.rstheme"
View the help documentation