Package goodpractice

Similar documents
Package rcmdcheck. R topics documented: November 10, 2018

Package spark. July 21, 2017

Package available. November 17, 2017

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package rhub. November 1, 2017

Package fastdummies. January 8, 2018

Package sessioninfo. June 21, 2017

Package desc. May 1, 2018

Package ECctmc. May 1, 2018

Package zip. R topics documented: March 11, Title Cross-Platform 'zip' Compression Version 2.0.1

Package dkanr. July 12, 2018

Package knitrprogressbar

Package canvasxpress

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package validara. October 19, 2017

Package messaging. May 27, 2018

Package SEMrushR. November 3, 2018

Package virustotal. May 1, 2017

Package fitbitscraper

Package internetarchive

Package robotstxt. November 12, 2017

Package repec. August 31, 2018

Package cli. November 5, 2017

Package githubinstall

Package calpassapi. August 25, 2018

Package rwars. January 14, 2017

Package loggit. April 9, 2018

Package kdtools. April 26, 2018

Package data.world. April 5, 2018

Package crossword.r. January 19, 2018

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package modules. July 22, 2017

Package condusco. November 8, 2017

Package pdfsearch. July 10, 2018

Package postgistools

Package facerec. May 14, 2018

Package censusapi. August 19, 2018

Package patentsview. July 12, 2017

Package wikitaxa. December 21, 2017

Package filelock. R topics documented: February 7, 2018

Package SNPediaR. April 9, 2019

Package spelling. December 18, 2017

Package opencage. January 16, 2018

Package pkgbuild. October 16, 2018

Package docxtools. July 6, 2018

Package shinytest. May 7, 2018

Package rzeit2. January 7, 2019

Package semver. January 6, 2017

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package liftr. R topics documented: May 14, Type Package

Package stapler. November 27, 2017

Package lumberjack. R topics documented: July 20, 2018

Package gtrendsr. October 19, 2017

Package rbraries. April 18, 2018

Package sankey. R topics documented: October 22, 2017

Package styler. December 11, Title Non-Invasive Pretty Printing of R Code Version 1.0.0

Package dbx. July 5, 2018

Package rgho. R topics documented: January 18, 2017

Package jug. April 13, 2017

Package algorithmia. September 13, 2016

Package pkgload. July 8, 2018

Package jpmesh. December 4, 2017

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package widyr. August 14, 2017

Package guardianapi. February 3, 2019

Package IRkernel. January 7, 2019

Package bisect. April 16, 2018

Package cloudml. June 12, 2018

Package covr. October 18, 2018

Package gtrendsr. August 4, 2018

Package statsdk. September 30, 2017

Package eply. April 6, 2018

Package sfdct. August 29, 2017

Package deductive. June 2, 2017

Package clipr. June 23, 2018

Package radix. September 17, 2018

Package oec. R topics documented: May 11, Type Package

Package essurvey. August 23, 2018

Package BiocManager. November 13, 2018

Package slickr. March 6, 2018

Package datasets.load

Package datapasta. January 24, 2018

Package wdman. January 23, 2017

Package triebeard. August 29, 2016

Package ezknitr. September 16, 2016

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package farver. November 20, 2018

Package cancensus. February 4, 2018

Package qualmap. R topics documented: September 12, Type Package

Package ssh. June 4, 2018

Package nlgeocoder. October 8, 2018

Package tiler. June 9, 2018

Package editdata. October 7, 2017

Package gifti. February 1, 2018

Package shinyfeedback

Package readxl. April 18, 2017

Package edfreader. R topics documented: May 21, 2017

Package exifr. October 15, 2017

Package vinereg. August 10, 2018

Package aws.transcribe

Transcription:

Title Advice on R Package Building Version 1.0.2 Package goodpractice May 2, 2018 Give advice about good practices when building R packages. Advice includes functions and syntax to avoid, package structure, code complexity, code formatting, etc. License MIT + file LICENSE LazyData true URL https://github.com/mangothecat/goodpractice BugReports https://github.com/mangothecat/goodpractice/issues RoxygenNote 6.0.1 Suggests testthat, knitr, rmarkdown Imports clisymbols, covr, crayon, cyclocomp (>= 1.1.0), desc, jsonlite, lintr, praise, rcmdcheck, rstudioapi, tools, utils, whoami, withr, xml2, xmlparsedata (>= 1.0.1) Collate 'api.r' 'customization.r' 'lists.r' 'chk_covr.r' 'chk_cyclocomp.r' 'chk_description.r' 'chk_lintr.r' 'chk_namespace.r' 'chk_rcmdcheck.r' 'chk_tnf.r' '.R' 'my_linters.r' 'package.r' 'prep_covr.r' 'prep_cyclocomp.r' 'prep_description.r' 'prep_expressions.r' 'prep_lintr.r' 'prep_namespace.r' 'prep_rcmdcheck.r' 'print.r' 'rstudio_markers.r' 'utils.r' VignetteBuilder knitr NeedsCompilation no Author Gabor Csardi [aut], Hannah Frick [aut, cre] Maintainer Hannah Frick <hfrick@mango-solutions.com> Repository CRAN Date/Publication 2018-05-02 19:03:36 UTC 1

2 goodpractice-package R topics documented: goodpractice-package.................................... 2 all_checks.......................................... 3 checks............................................ 3 export_json......................................... 4 failed_checks........................................ 4 failed_positions....................................... 5.............................................. 5 make_check......................................... 6 make_prep.......................................... 7 results............................................ 7 Index 9 goodpractice-package goodpractice: 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. Author(s) Maintainer: Hannah Frick <hfrick@mango-solutions.com> Authors: Gabor Csardi <csardi.gabor@gmail.com> See Also Useful links: https://github.com/mangothecat/goodpractice Report bugs at https://github.com/mangothecat/goodpractice/issues

all_checks 3 all_checks List the names of all checks List the names of all checks all_checks() Character vector of checks checks List all checks performed List all checks performed checks() output. Character vector of check names. See Also Other API: failed_checks, results path <- system.file("bad1", package = "goodpractice") # run a subset of all checks available g <- (path, checks = all_checks()[3:16]) checks(g)

4 failed_checks export_json Export failed checks to JSON Export failed checks to JSON export_json(, file, pretty = FALSE) file pretty output. Output connection or file. Whether to pretty-print the JSON. failed_checks Names of the failed checks Names of the failed checks failed_checks() output. See Also Names of the failed checks. Other API: checks, results path <- system.file("bad1", package = "goodpractice") # run a subset of all checks available g <- (path, checks = all_checks()[3:16]) failed_checks(g)

failed_positions 5 failed_positions Positions of check failures in the source code Note that not all checks refer to the source code. For these the result will be NULL. failed_positions() output. Details For the ones that do, the results is a list, one for each failure. Since the same check can fail multiple times. A single failure is a list with entries: filename, line_number, column_number, ranges. ranges is a list of pairs of start and end positions for each line involved in the check. A list of lists of positions. See details below. Run good practice checks To see the results, just print it to the screen. (path = ".", checks = all_checks(), extra_preps = NULL, extra_checks = NULL, quiet = TRUE) path checks extra_preps extra_checks quiet Path to a package root. Character vector, the checks to run. Defaults to all checks. Use all_checks to list all checks. Custom preparation functions. See make_prep on creating preparation functions. Custom checks. See make_check on creating checks. Whether to suppress output from the preparation functions. Note that not all preparation functions produce output, even if this option is set to FALSE.

6 make_check A goodpractice object that you can query with a simple API. See results to start. path <- system.file("bad1", package = "goodpractice") # run a subset of all checks available g <- (path, checks = all_checks()[3:16]) g make_check Create a check function Create a check function make_check(description, check,,...) description check A description of the check.... Further arguments. A function that takes the state as an argument. A short description of what is good practice. # make a preparation function url_prep <- make_prep( name = "desc", func = function(path, quiet) desc::description$new(path) ) # and the corresponding check function url_chk <- make_check( description = "URL field in DESCRIPTION", tags = character(), preps = "desc", = "have a URL field in DESCRIPTION", check = function(state) state$desc$has_fields("url") ) # use together in () bad1 <- system.file("bad1", package = "goodpractice") res <- (bad1, checks = "no_description_depends", extra_preps = list("desc" = url_prep), extra_checks = list("url" = url_chk))

make_prep 7 make_prep Create a preparation function Create a preparation function make_prep(name, func) name func Name of the preparation function. A function that takes two arguments: The path to the root directory of the package, and a logical argument: quiet. If quiet is true, the preparation function may print out diagnostic messages. # make a preparation function url_prep <- make_prep( name = "desc", func = function(path, quiet) desc::description$new(path) ) # and the corresponding check function url_chk <- make_check( description = "URL field in DESCRIPTION", tags = character(), preps = "desc", = "have a URL field in DESCRIPTION", check = function(state) state$desc$has_fields("url") ) # use together in () bad1 <- system.file("bad1", package = "goodpractice") res <- (bad1, checks = "no_description_depends", extra_preps = list("desc" = url_prep), extra_checks = list("url" = url_chk)) results Return all check results in a data frame Return all check results in a data frame

8 results results() output. Data frame, with columns: check result The name of the check. Logical, whether it has failed or not. See Also Other API: checks, failed_checks path <- system.file("bad1", package = "goodpractice") # run a subset of all checks available g <- (path, checks = all_checks()[3:16]) results(g)

Index all_checks, 3, 5 checks, 3, 4, 8 export_json, 4 failed_checks, 3, 4, 8 failed_positions, 5 goodpractice (), 5 goodpractice-package, 2, 3 5, 5, 8 make_check, 5, 6 make_prep, 5, 7 results, 3, 4, 6, 7 9