-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
101 lines (73 loc) · 2.66 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# dfuzz
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/dfuzz)](https://CRAN.R-project.org/package=dfuzz)
<!-- badges: end -->
The goal of __{dfuzz}__ is to help you cleaning up a messy column of strings
of characters in your `tibble` or `data.frame`.
This package is __highly experimental__ and is not yet ready for being used for real applications.
It is build around two dependencies which themselves have no dependencies:
- [__{rlang}__](https://github.com/r-lib/rlang)
- [__{stringdist}__](https://github.com/markvanderloo/stringdist), and it is possible to use the full power of the function `stringdist()` from this excellent package.
__{dfuzz}__ aims at being compatible with both _tidyverse_ and _base_ R dialects.
## Installation
You can install this package using __{remotes}__ (or __{devtools}__):
```r
remotes::install_github("courtiol/dfuzz")
```
## Example
```{r example}
library(dfuzz)
## a toy example:
test_df <- data.frame(fruit = c("banana", "blueberry", "limon", "pinapple",
"aple", "apple", "ApplE", "bonana"))
test_df
## fast and dirty workflow:
clean_df1 <- fuzzy_tidy(test_df, fruit)
clean_df1
## more subtle workflow:
template_fruit <- fuzzy_match(test_df, fruit)
template_fruit
template_fruit$selected[1] <- "apple"
clean_df2 <- fuzzy_tidy(test_df, fruit, template_fruit)
clean_df2
## fast and dirty workflow with {tidyverse}:
library(tidyverse)
test_df %>%
fuzzy_tidy(fruit) %>%
mutate(fruit = fruit.tidy) %>%
select(-contains("fruit."))
## more subtle workflow with {tidyverse}:
test_df %>%
mutate(fruit = str_to_title(fruit)) %>%
fuzzy_match(fruit) -> template_fruit
template_fruit
template_fruit %>%
mutate(selected = fct_recode(selected, Apple = "Aple")) -> better_template_fruit
better_template_fruit
test_df %>%
mutate(fruit = str_to_title(fruit)) %>%
fuzzy_tidy(fruit, better_template_fruit) -> clean_df3
clean_df3
clean_df3 %>%
mutate(fruit = fruit.tidy) %>%
select(-contains("fruit."))
```
## Help \& feedbacks wanted!
If you find that this package is an idea worth pursuing, please let me know.
Developing is always more fun when it becomes a collaborative work.
So please also email me (or leave an issue) if you want to get involved!