Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/evamaerey/greenhistogram


https://github.com/evamaerey/greenhistogram

Last synced: 11 days ago
JSON representation

Awesome Lists containing this project

README

        

---
output:
github_document:
toc: TRUE
toc_depth: 2
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = T
)
```

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)

# Part 0. Proposal

Proposing the {greenhistogram} package! 🦄

The goal of {greenhistogram} is to make ... easier.

Without the package, we live in the effort-ful world that follows 🏋:

```{r}
library(ggplot2)

ggplot(cars, aes(dist)) +
geom_histogram(fill = "green")
```


With the {greenhistogram} package, we'll live in a different world (🦄 🦄 🦄) where the task is a snap 🫰:

Proposed API:

```

library(greenhistogram)

ggplot(cars, aes(dist)) +
geom_histogram_green()

```

# Part I. Work out functionality ✅

Here is a function that will do some work...

```{r geom_histogram_green}
geom_histogram_green <- function(...){

ggplot2::geom_histogram(fill = "green", ...)

}
```

## Try it out

```{r}
ggplot(cars, aes(dist)) +
geom_histogram_green()
```

# Part II. Packaging and documentation 🚧 ✅

## Phase 1. Minimal working package

### Bit A. Created package archetecture, running `devtools::create(".")` in interactive session. 🚧 ✅

```{r, eval = F}
devtools::create(".")
```

### Bit B. Managing [dependencies](https://r-pkgs.org/dependencies-in-practice.html)? 🚧 ✅

Dependencies must be declared in your package.

This means ...

1. you'll use the `::` notation, e.g. `package::function()` in your functions when you use another package's functions (i.e. not base R function).
2. you'll send package dependencies to your DESCRIPTION
file; which can be done automatically with `usethis::use_package`:

```{r, eval = F}
usethis::use_package("ggplot2")
```

### Bit C. Moved functions [R code folder](https://r-pkgs.org/code.html)? 🚧 ✅

Use new {readme2pkg} function to do this from readme...

```{r, eval = F}
readme2pkg::chunk_to_r(chunk_name = "geom_histogram_green")
```

### Bit D. Run [`devtools::check()`](https://r-pkgs.org/whole-game.html#check) and address errors. 🚧 ✅

```{r, eval = F}
devtools::check(pkg = ".")
```

devtools check will document the functions for you.

### Bit E. [Install](https://r-pkgs.org/whole-game.html#install) and restart package 🚧 ✅

```{r, eval = F}
devtools::install(pkg = ".", upgrade = 'never')
```

### Bit F. Write traditional README that uses built package (also serves as a test of build). 🚧 ✅

The goal of the {greenhistogram} package is to ...

Install package with:

```
remotes::install_github("EvaMaeRey/greenhistogram")
```

Once functions are exported you can remove go to two colons, and when things are are really finalized, then go without colons (and rearrange your readme...)

```{r, eval = F}
library(ggplot2)
library(greenhistogram) ##<< change to your package name here

ggplot(cars, aes(dist)) +
greenhistogram:::geom_histogram_green()
```

### Bit G. Add [lifecycle badge](https://r-pkgs.org/lifecycle.html) (experimental) 🚧 ✅

```{r, eval = F}
usethis::use_lifecycle_badge("experimental")
```

### Bit H. Compile README.Rmd 🚧 ✅

### Bit I. Push to github. 🚧 ✅

RStudio: Console/Terminal/RMarkdown/Jobs:

Terminal -> git add . -> git commit -m "first commit" -> git push

## Phase 2: Listen & iterate 🚧 ✅

Try to get feedback from experts on API, implementation, default decisions. Is there already work that solves this problem?

## Phase 3: Settling and testing 🚧 ✅

### Bit A. Added a description and author information in the [DESCRIPTION file](https://r-pkgs.org/description.html) 🚧 ✅

### Bit B. Added [roxygen skeleton](https://r-pkgs.org/man.html)? 🚧 ✅

Use a roxygen skeleton for auto documentation and making sure proposed functions are *exported*. (in RStudio 'Code -> insert Roxygen Skeleton) Generally, early on, I don't do much (anything) in terms of filling in the skeleton for documentation, because things may change.

### Bit C. Chosen a [license](https://r-pkgs.org/license.html)? 🚧 ✅

```{r, eval = F}
usethis::use_mit_license()
```

### Bit D. Settle on [examples](https://r-pkgs.org/man.html#sec-man-examples). Put them in the roxygen skeleton and readme. 🚧 ✅

### Bit E. Written formal [tests](https://r-pkgs.org/testing-basics.html) of functions and save to test that folders 🚧 ✅

That would look like this...

```{r test_calc_times_two_works, eval = F}
library(testthat)

test_that("calc times 2 works", {
expect_equal(times_two(4), 8)
expect_equal(times_two(5), 10)

})
```

```{r, eval = F}
readme2pkg::chunk_to_tests_testthat("test_calc_times_two_works")
```

### Bit F. Check again. Addressed notes, warnings and errors. 🚧 ✅

```{r, eval = F}
devtools::check(pkg = ".")
```

## Phase 4. Promote to wider audience... 🚧 ✅

### Bit A. Package website built? 🚧 ✅

### Bit B. Package website deployed? 🚧 ✅

## Phase 5: Harden/commit: Submit to CRAN/RUniverse 🚧 ✅

# Appendix: Reports, Environment

## Description file complete? 🚧 ✅

```{r, eval = F}
readLines("DESCRIPTION")
```

## Environment 🚧 ✅

Here I just want to print the packages and the versions

```{r}
all <- sessionInfo() |> print() |> capture.output()
all[11:17]
```

## `devtools::check()` report

```{r, eval=F, error = T, results="hide", warning=F}
devtools::check(pkg = ".")
```

## Package directory file tree

```{r}
fs::dir_tree(recurse = T)
```