Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mkearney/tfse

๐Ÿ›  Useful R functions for various things
https://github.com/mkearney/tfse

data-science functions mkearney-r-package r-language rstats utility

Last synced: about 1 month ago
JSON representation

๐Ÿ›  Useful R functions for various things

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, echo = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
set.seed(1234)
## load pkg
library(tfse)
```

# tfse

[![Travis build status](https://travis-ci.org/mkearney/tfse.svg?branch=master)](https://travis-ci.org/mkearney/tfse)
[![Coverage status](https://codecov.io/gh/mkearney/tfse/branch/master/graph/badge.svg)](https://codecov.io/github/mkearney/tfse?branch=master)

[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)

Various useful functions for working with data and writing functions

## Install

Install from CRAN

```{r, eval=FALSE}
## from CRAN repo
install.packages("tfse")
```

Install dev version from Github

```{r, eval=FALSE}
## from github
remotes::install_github("mkearney/tfse")
```

## Usage

### Scales

Rescale to standard (0-1) scale

```{r}
## 0-1 scale
rescale_standard(-2:2)
```

Rescale to normal (mean = 0; sd = 1) scale

```{r}
## z scores
rescale_normal(-2:2)
```

Rescale to arbitrary lower/upper bounds

```{r}
## specify new scale bounds
rescale_pointscale(-2:2, 1, 10)
```

### Citations

Print out the APA-formatted citation for R packages.

```{r}
## print out APA citation for {rtweet}
apa_citation("rtweet")
```

### Annotate script files

Use `box_code()` to add a header-like chunk to your clipboardโ€“paste in script as desired.

```{r}
## store text in clipboard
box_code("EXAMPLE #1")

## the pasted output:
##----------------------------------------------------------------------------##
## EXAMPLE #1 ##
##----------------------------------------------------------------------------##
```

### Regular expressions

Get all regular expression matches (using easier looka-heads/look-behinds)

```{r}
## 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)
```

### Github

Figure out the name of a Github repo for a given package

```{r}
## repo name of devtools
desc_gh_repo("devtools")
```

Convert a Github link to the raw URL version

```{r}
## path to raw version of Github file
github_raw("https://github.com/mkearney/driven-snow/blob/master/theme/driven-snow.rstheme")
```

## Help

View the help documentation

```{r, eval=FALSE}
## view R help documentatoin
help(package = "tfse")
```

## about tfse
- This is my personal R package of utility functions
- Why *tfse*? The acronym was creatively reconfigured from its
originally intended state