https://github.com/rahmanda/boilerrplate
An R Project boilerplate
https://github.com/rahmanda/boilerrplate
boilerplate r
Last synced: about 2 months ago
JSON representation
An R Project boilerplate
- Host: GitHub
- URL: https://github.com/rahmanda/boilerrplate
- Owner: rahmanda
- License: other
- Created: 2021-08-31T13:56:54.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T15:47:20.000Z (over 3 years ago)
- Last Synced: 2025-01-02T05:21:57.342Z (3 months ago)
- Topics: boilerplate, r
- Language: R
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - rahmanda/boilerrplate - An R Project boilerplate (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```**NOTE: This is a toy package created for expository purposes, for the second edition of [R Packages](https://r-pkgs.org). It is not meant to actually be useful. If you want a package for factor handling, please see [forcats](https://forcats.tidyverse.org).**
# boilerrplate
[](https://github.com/rahmanda/boilerrplate/actions)
Factors are a very useful type of variable in R, but they can also be very aggravating. This package provides some helper functions for the care and feeding of factors.
## Installation
You can install boilerrplate like so:
``` r
devtools::install_github("rahmanda/boilerrplate")## Quick demo
Binding two factors via `fbind()`:
```{r}
library(boilerrplate)
a <- factor(c("character", "hits", "your", "eyeballs"))
b <- factor(c("but", "integer", "where it", "counts"))
```Simply catenating two factors leads to a result that most don't expect.
```{r}
c(a, b)
```The `fbind()` function glues two factors together and returns factor.
```{r}
fbind(a, b)
```Often we want a table of frequencies for the levels of a factor. The base `table()` function returns an object of class `table`, which can be inconvenient for downstream work.
```{r}
set.seed(1234)
x <- factor(sample(letters[1:5], size = 100, replace = TRUE))
table(x)
```The `fcount()` function returns a frequency table as a tibble with a column of factor levels and another of frequencies:
```{r}
fcount(x)
```