Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs (#104) #111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ README.html
^.*\.Rproj$
^\.Rproj\.user$
docs/
^\.github$
^data-raw$
^_pkgdown\.yml$
^docs$
^pkgdown$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
42 changes: 42 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
push:
branches: master

name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master

- uses: r-lib/actions/setup-pandoc@master

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2)
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: macOS-r-3.6-${{ hashFiles('depends.Rds') }}
restore-keys: macOS-r-3.6-

- name: Install dependencies
run: |
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)
remotes::install_dev("pkgdown")
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: pkgdown::deploy_to_branch(new_process = FALSE)
shell: Rscript {0}
19 changes: 10 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Suggests:
outbreaks,
incidence,
testthat,
knitr,
roxygen2,
covr,
tibble,
dplyr,
magrittr
outbreaks,
incidence,
testthat,
knitr,
roxygen2,
covr,
tibble,
dplyr,
magrittr,
rmarkdown
RoxygenNote: 7.0.2
Imports:
matchmaker (>= 0.1.0),
Expand Down
8 changes: 8 additions & 0 deletions R/linelist-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' @keywords internal
"_PACKAGE"

# The following block is used by usethis to automatically manage
# roxygen namespace tags. Modify with care!
## usethis namespace: start
## usethis namespace: end
NULL
61 changes: 17 additions & 44 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ knitr::opts_chunk$set(
[![Codecov test coverage](https://codecov.io/gh/reconhub/linelist/branch/master/graph/badge.svg)](https://codecov.io/gh/reconhub/linelist?branch=master)

This package is dedicated to simplifying the cleaning and standardisation of
linelist data. Considering a case linelist `data.frame`, it aims to:
[line list](https://outbreaktools.ca/background/line-lists/) data. Considering a case line list `data.frame`, it aims to:

- standardise the variables names, replacing all non-ascii characters with their
closest latin equivalent, removing blank spaces and other separators,
Expand Down Expand Up @@ -54,10 +54,24 @@ devtools::install_github("reconhub/linelist")

Note that this requires the package *devtools* installed.

# Quick example

# What does it do?
Let us consider a messy `data.frame` as an example:

## Data cleaning
```{r toy_data}
library(linelist)
example_data <- messy_data(10)
example_data
```

We then use the `clean_data()` command to get nice, clean data!

```{r clean_data}
clean_data(example_data, guess_dates = TRUE)
```


# What does it do?

Procedures to clean data, first and foremost aimed at `data.frame` formats,
include:
Expand All @@ -78,47 +92,6 @@ include:
- `guess_dates()`: find dates in various, unspecified formats in a messy
`character` vector



# Worked example

Let us consider some messy `data.frame` as a toy example:

```{r toy_data}

## make toy data
onsets <- as.Date("2018-01-01") + sample(1:10, 20, replace = TRUE)
discharge <- format(as.Date(onsets) + 10, "%d/%m/%Y")
genders <- c("male", "female", "FEMALE", "Male", "Female", "MALE")
gender <- sample(genders, 20, replace = TRUE)
case_types <- c("confirmed", "probable", "suspected", "not a case",
"Confirmed", "PROBABLE", "suspected ", "Not.a.Case")
messy_dates <- sample(
c("01-12-2001", "male", "female", "2018-10-18", "2018_10_17",
"2018 10 19", "// 24//12//1989", NA, "that's 24/12/1989!"),
20, replace = TRUE)
case <- factor(sample(case_types, 20, replace = TRUE))
toy_data <- data.frame("Date of Onset." = onsets,
"DisCharge.." = discharge,
"SeX_ " = gender,
"Épi.Case_définition" = case,
"messy/dates" = messy_dates)
## show data
toy_data

```

We start by cleaning these data:

```{r clean_data}
## load library
library(linelist)

## clean data with defaults
x <- clean_data(toy_data)
x

```



Expand Down
Loading