• Stars
    star
    420
  • Rank 99,443 (Top 3 %)
  • Language
    R
  • License
    Other
  • Created over 8 years ago
  • Updated 8 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Advice on R Package Building

goodpractice

R-CMD-check CRAN status CRAN RStudio mirror downloads Codecov test coverage

Advice on R Package Building

Give advice about good practices when building R packages. Advice includes functions and syntax to avoid, package structure, code complexity, code formatting, etc.

Installation

You can install the release version from CRAN

install.packages("goodpractice")

and the development version from GitHub

remotes::install_github("mangothecat/goodpractice")

Usage

library(goodpractice)
gp("<my-package>")

Example

library(goodpractice)
# use example package contained in the goodpractice package
pkg_path <- system.file("bad1", package = "goodpractice")
g <- gp(pkg_path)
#> 
#> * checking for file โ€˜/tmp/Rtmpel0L5F/remotesd7c53a259c/badpackage/DESCRIPTIONโ€™ ... OK
#> * preparing โ€˜badpackageโ€™:
#> * checking DESCRIPTION meta-information ... OK
#> * checking vignette meta-information ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> * building โ€˜badpackage_1.0.0.tar.gzโ€™
g
#> โ”€โ”€ GP badpackage โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#> 
#> It is good practice to
#> 
#>   โœ– not use "Depends" in DESCRIPTION, as it can cause name clashes, and
#>     poor interaction with other packages. Use "Imports" instead.
#>   โœ– omit "Date" in DESCRIPTION. It is not required and it gets invalid
#>     quite often. A build date will be added to the package when you
#>     perform `R CMD build` on it.
#>   โœ– add a "URL" field to DESCRIPTION. It helps users find information
#>     about your package online. If your package does not have a
#>     homepage, add an URL to GitHub, or the CRAN package package page.
#>   โœ– add a "BugReports" field to DESCRIPTION, and point it to a bug
#>     tracker. Many online code hosting services provide bug trackers for
#>     free, https://github.com, https://gitlab.com, etc.
#>   โœ– omit trailing semicolons from code lines. They are not needed and
#>     most R coding standards forbid them
#> 
#>     R/semicolons.R:4:30
#>     R/semicolons.R:5:29
#>     R/semicolons.R:9:38
#> 
#>   โœ– not import packages as a whole, as this can cause name clashes
#>     between the imported packages. Instead, import only the specific
#>     functions you need.
#>   โœ– fix this R CMD check ERROR: VignetteBuilder package not declared:
#>     โ€˜knitrโ€™ See section โ€˜The DESCRIPTION fileโ€™ in the โ€˜Writing R
#>     Extensionsโ€™ manual.
#>   โœ– avoid 'T' and 'F', as they are just variables which are set to the
#>     logicals 'TRUE' and 'FALSE' by default, but are not reserved words
#>     and hence can be overwritten by the user.  Hence, one should always
#>     use 'TRUE' and 'FALSE' for the logicals.
#> 
#>     R/tf.R:NA:NA
#>     R/tf.R:NA:NA
#>     R/tf.R:NA:NA
#>     R/tf.R:NA:NA
#>     R/tf.R:NA:NA
#>     ... and 4 more lines
#> 
#> โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# show all available checks
# all_checks()

# run only a specific check
g_url <- gp(pkg_path, checks = "description_url")
g_url
#> โ”€โ”€ GP badpackage โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#> 
#> It is good practice to
#> 
#>   โœ– add a "URL" field to DESCRIPTION. It helps users find information
#>     about your package online. If your package does not have a
#>     homepage, add an URL to GitHub, or the CRAN package package page.
#> โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# which checks were carried out?
checks(g_url)
#> [1] "description_url"
# which checks failed?
failed_checks(g)
#> [1] "no_description_depends"                
#> [2] "no_description_date"                   
#> [3] "description_url"                       
#> [4] "description_bugreports"                
#> [5] "lintr_trailing_semicolon_linter"       
#> [6] "no_import_package_as_a_whole"          
#> [7] "rcmdcheck_package_dependencies_present"
#> [8] "truefalse_not_tf"
# show the first 5 checks carried out and their results
results(g)[1:5,]
#>                    check result
#> 1                   covr     NA
#> 2              cyclocomp   TRUE
#> 3 no_description_depends  FALSE
#> 4    no_description_date  FALSE
#> 5        description_url  FALSE

License

MIT ยฉ 2022 Ascent Digital Services UK Limited

More Repositories

1

rmdshower

R Markdown template for shower
R
147
star
2

shinytoastr

Notifications in Shiny apps
R
91
star
3

python-for-r-users-workshop

Material for the Python for R Users workshop
Jupyter Notebook
72
star
4

radarchart

Implementation of the radar chart from chart.js library
R
68
star
5

tidyshiny

Interactively generate function calls for the tidyr package
R
68
star
6

dynshiny

Example Shiny app for dynamically building a UI from a database
R
57
star
7

franc

Detect the Language of Text
R
53
star
8

cyclocomp

Cyclomatic complexity of R functions and expressions
R
46
star
9

keras-workshop

Data and scripts for keras course
R
44
star
10

pkgsnap

(Re)install certain versions of CRAN packages
R
43
star
11

rematch2

Tidy output from regular expression matches
R
41
star
12

functionMap

Draw the functions map for a R package
R
36
star
13

github-workshop

R Development Using GitHub
CSS
35
star
14

tracer

Slick call stack traces
R
35
star
15

testCoverage

R Code Coverage Package
R
33
star
16

dtdbshiny

Shiny app demo of database bulk update and inline editing
R
29
star
17

shinyAppDemo

A demo shiny app inside a package
R
28
star
18

visualTest

Fuzzy testing of graphical files
R
27
star
19

rematch

Match regular expressions with a nicer API
R
24
star
20

sankey

Sankey Diagrams
R
24
star
21

explainable-machine-learning-workshop

Material for the Explainable Machine Learning Workshop
R
18
star
22

blog_installing_packages

Blogpost about installing packages and getting package dependencies
HTML
17
star
23

xmlparsedata

R code parse data as an XML tree
R
17
star
24

boardPack

A shiny application, leveraging shiny modules
R
10
star
25

shiny_beyond_the_basics

Scripts and Exercises for Shiny Beyond the Basics
R
10
star
26

Introduction-to-Functional-Programming-with-Purrr

EARL workshop for Introduction to Functional Programming with Purrr
R
10
star
27

blog_worldcup2018

Blogpost about predicting World Cup 2018
R
10
star
28

Modelling-Airbnb-Prices

Modelling Airbnb prices in London using different Machine Learning models (Random Forest, Gradient Boosting, Neural Network)
HTML
10
star
29

NewsArticleClustering

Proof of concept work for clustering of news articles from RSS feeds
R
9
star
30

mangoTraining

R package containing datasets used for Mango Solutions training courses and for the book SAMS Teach Yourself R in 24 Hours.
R
8
star
31

sasMap

Static Code Analysis of SAS scripts
R
8
star
32

Advanced-Shiny-Training

Example and Exercise Solutions
R
8
star
33

londonRShinyWorkshop2017

R
7
star
34

rstack

Minimal stack data type
R
6
star
35

packageMetrics2

Collect Metrics about R Packages
R
6
star
36

Formal-Package-Development-Workshop

Resources for the EARL Current Best Practices in Formal Package Development Workshop
R
6
star
37

RNMImport

Tools for importing and manipulating NONMEM data
R
6
star
38

BLCOP

Black-Litterman and copula-opinion pooling frameworks
R
5
star
39

GoTr

R wrapper for An API of Ice And Fire
R
5
star
40

MangoPresentations

Mango presentations
R
5
star
41

simplegraph

Simple Graph Data Types and Basic Algorithms
R
5
star
42

making-r-go-faster-workshop

Scripts and Exercises for Making R Go Faster Workshop
R
5
star
43

earl2019-shiny

Materials for the "Shiny for Production" workshop at EARL London 2019
R
5
star
44

swli

Star Wars Lorem Ipsum generator
R
5
star
45

rmdshower.mango

Mango theme for rmdshower
HTML
4
star
46

web-scraping-text-mining-workshop

Files needed for the web scraping and text mining workshop
CSS
4
star
47

blog_GoTr

blogpost about GoTr and house network analysis
HTML
4
star
48

ShinyTraining

Example Shiny applications used in Mango Shiny training courses
R
4
star
49

autoPricing

Automated glm pricing analysis for frequency and severity models
R
3
star
50

keyring

Access the System Keyring from R
C++
3
star
51

ismydatabig

The ismydatabig.com web site
JavaScript
3
star
52

blog_analysis_abstracts

Blogpost analysing EARL abstracts using tidytext
HTML
3
star
53

docker-buildr

An r-ver image with extra build dependencies
Dockerfile
3
star
54

intro-to-shiny-workshop

Introduction to Shiny
R
3
star
55

ShinyDashboard

R
3
star
56

awesome-shiny

Awesome shiny apps
2
star
57

Olympic-Funding-Data

Data from UK Sport on funding of olympic sports teams
2
star
58

email-screenshot

NPM package to take screenshot of web pages and send them to email addresses
JavaScript
2
star
59

showimage

Show an image on the R graphics device
R
2
star
60

fftw3

FFTW3 Fourier Transform Library in an R Package
C
2
star
61

blog_sasmap

Blogpost about the sasMap package
HTML
2
star
62

blog_bowie_tidytext

HTML
2
star
63

blog_fun_data

blogpost about open data that is fun
HTML
2
star
64

praise

A R package to praise all the userRs
R
2
star
65

symbolicR

Symbolic operation functions, including simplifier, symbolic match functions and rule based simplifier generator.
R
2
star
66

blog_in_between

blogpost about doing a conditional join
HTML
2
star
67

cranbrowser

R
1
star
68

satrdays2016

Gabor's talk at satRdays 20016
Makefile
1
star
69

satrdays_cardiff_talk_reticulate

Presentation given at SatRdays Cardiff 2018 on the use of the reticulate package
1
star
70

docker-minipydata

A docker image of the key parts of the pydata ecosystem
Python
1
star
71

workshop-sparklyr-odsc-2017

Material from the sparklyr workshop 2017
R
1
star
72

mailman

R package for a wrapper around the python mailbox module
R
1
star
73

shower-mango

Mango theme for Shower HTML presentation engine
CSS
1
star
74

cran-browser-ext

JavaScript
1
star
75

blog_rstats_gender

Blogpost about gender distribution within rstats community
HTML
1
star
76

mangoNCA

R
1
star
77

Women-in-Data

R
1
star
78

blog-with-mock

Blog post about mocking with testthat::with_mock
HTML
1
star
79

rss-2018-hackathon

Material for the hackathon event at the RSS Conference 2018
1
star
80

rmdshower.earl2016

EARL 2016 theme for Shower HTML presentation engine
HTML
1
star
81

dbloadss

Test SQL Server Load Times
R
1
star
82

azuremlweb

Call an AzureML web service from R
R
1
star
83

slideBreakR

An R package for splitting tables up over multiple slides using knitr, rmarkdown and slidy.
R
1
star
84

exeter-r-programming-dplyr

Programming with dplyr using tidyeval, presentation at Exeter R user group June meetup
1
star
85

docker-docker-gcpsdk

Docker-in-Docker with GCP SDK
Dockerfile
1
star
86

shinyconf-2023-js-library

Presentation for ShinyConf 2023
HTML
1
star
87

blog_Gender-diversity-film-industry

This project focuses on some key behind-the-camera roles in the film industry to measure the evolution of their gender diversity in the last decade, from 2007 until 2017.
R
1
star