Package assertive.data

Similar documents
Package assertive.code

Package assertive.properties

Package assertive.reflection

Package assertive.types

Package roperators. September 28, 2018

Package poio. R topics documented: January 29, 2017

Package fastdummies. January 8, 2018

Package errorlocate. R topics documented: March 30, Type Package Title Locate Errors with Validation Rules Version 0.1.3

Package lvec. May 24, 2018

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

Package triebeard. August 29, 2016

Package deductive. June 2, 2017

Package zebu. R topics documented: October 24, 2017

Package labelvector. July 28, 2018

Package ECctmc. May 1, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package rtext. January 23, 2019

Package datasets.load

Package sfc. August 29, 2016

Package tidyimpute. March 5, 2018

Package repec. August 31, 2018

Package librarian. R topics documented:

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package mdftracks. February 6, 2017

Package strat. November 23, 2016

Package rgho. R topics documented: January 18, 2017

Package narray. January 28, 2018

Package validara. October 19, 2017

Package readmzxmldata

Package statip. July 31, 2018

Package infer. July 11, Type Package Title Tidy Statistical Inference Version 0.3.0

Package meme. November 2, 2017

Package stapler. November 27, 2017

Package messaging. May 27, 2018

Package raker. October 10, 2017

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

Package hyphenatr. August 29, 2016

Package condformat. October 19, 2017

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

Package scrubr. August 29, 2016

Package autocogs. September 22, Title Automatic Cognostic Summaries Version 0.1.1

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package labelled. December 19, 2017

Package available. November 17, 2017

Package meme. December 6, 2017

Package testit. R topics documented: June 14, 2018

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

Package curry. September 28, 2016

Package lumberjack. R topics documented: July 20, 2018

Package graphframes. June 21, 2018

Package vinereg. August 10, 2018

Package HGNChelper. August 29, 2017

Package nodbi. August 1, 2018

Package hashids. August 29, 2016

Package sylcount. April 7, 2017

Package splithalf. March 17, 2018

Package ezsummary. August 29, 2016

Package dbx. July 5, 2018

Package LaF. November 20, 2017

Package rcba. May 27, 2018

Package kdtools. April 26, 2018

Package dat. January 20, 2018

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

Package rvest. R topics documented: August 29, Version Title Easily Harvest (Scrape) Web Pages

Package spelling. December 18, 2017

Package crochet. January 8, 2018

Package postgistools

Package SteinerNet. August 19, 2018

Package slam. December 1, 2016

Package humanize. R topics documented: April 4, Version Title Create Values for Human Consumption

R topics documented: 2 clone

Package restorepoint

Package slam. February 15, 2013

Package angstroms. May 1, 2017

Package kirby21.base

Package ggrepel. September 30, 2017

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package textstem. R topics documented:

Package sessioninfo. June 21, 2017

Package tm.plugin.lexisnexis

Package rgdax. January 7, 2019

Package bannercommenter

Package docxtools. July 6, 2018

Package widyr. August 14, 2017

Package githubinstall

Package simplecache. August 22, 2017

Package purrrlyr. R topics documented: May 13, Title Tools at the Intersection of 'purrr' and 'dplyr' Version 0.0.2

Package rebus.datetimes

Package spark. July 21, 2017

Package getopt. February 16, 2018

Package gtrendsr. August 4, 2018

Package confidence. July 2, 2017

Package CorporaCoCo. R topics documented: November 23, 2017

Package goodpractice

Package nima. May 23, 2018

Package readxl. April 18, 2017

Package fingertipsr. May 25, Type Package Version Title Fingertips Data for Public Health

Package Rspc. July 30, 2018

Package diagis. January 25, 2018

Package rbraries. April 18, 2018

Transcription:

Type Package Title Assertions to Check Properties of Data Version 0.0-1 Date 2015-10-06 Author Richard Cotton [aut, cre] Package assertive.data August 29, 2016 Maintainer Richard Cotton <richierocks@gmail.com> A set of predicates and assertions for checking the properties of (country independent comple data types. This is mainly for use by other package developers who want to include run-time testing features in their own packages. End-users will usually want to use assertive directly. URL https://bitbucket.org/richierocks/assertive.data BugReports https://bitbucket.org/richierocks/assertive.data/issues Depends R (>= 3.0.0 Imports assertive.base (>= 0.0-2, assertive.strings Suggests testthat, devtools License GPL (>= 3 LazyLoad yes LazyData yes Acknowledgments Development of this package was partially funded by the Proteomics Core at Weill Cornell Medical College in Qatar <http://qatar-weill.cornell.edu>. The Core is supported by 'Biomedical Research Program' funds, a program funded by Qatar Foundation. Collate 'imports.r' 'assert-is-data.r' 'is-data.r' NeedsCompilation no Repository CRAN Date/Publication 2015-10-06 15:56:43 1

2 assert_all_are_cas_numbers R topics documented: assert_all_are_cas_numbers................................ 2 assert_all_are_credit_card_numbers............................ 3 assert_all_are_email_addresses............................... 5 assert_all_are_he_colors.................................. 6 assert_all_are_honorifics.................................. 7 assert_all_are_ip_addresses................................. 8 assert_all_are_isbn_codes.................................. 9 Inde 11 assert_all_are_cas_numbers Does the character vector contain CAS registry numbers? Checks that the input contains Chemical Abstract Service registry numbers. assert_all_are_cas_numbers(, = FALSE, assert_any_are_cas_numbers(, = FALSE, is_cas_number( na.rm in many stats package functions, ecept that the position of the failing A logical vector that is TRUE when the input contains valid CAS registry numbers. CAS numbers take the form of 1 to 7 digits followed by a hyphen, followed by 2 digits, another hyphen and a final check digit.

assert_all_are_credit_card_numbers 3 References Chemspider (https://www.chemspider.com is a good service for looking up CAS numbers. Eamples <- c( water = "7732-18-5", d_glucose = "50-99-7", l_glucose = "921-60-8", no_hyphens = "7732185", two_check_digits = "7732-18-55", bad_check_digit = "7732-18-4", missing = NA is_cas_number( assert_any_are_cas_numbers( #These eamples should fail. assertive.base::dont_stop(assert_all_are_cas_numbers( assert_all_are_credit_card_numbers Does the character vector contain credit card numbers? Checks that the input contains credit card numbers. assert_all_are_credit_card_numbers(, = FALSE, assert_any_are_credit_card_numbers(, = FALSE, is_credit_card_number(, type = c("visa", "mastercard", "ame", "diners", "discover", "jcb" type na.rm in many stats package functions, ecept that the position of the failing Type of credit card. Multiple types can be selected.

4 assert_all_are_credit_card_numbers A logical vector that is TRUE when the input contains valid credit card numbers. Legacy card numbers, for eample 13 digit Visa numbers and 15 digits JCB numbers are not supported. References http://www.regular-epressions.info/creditcard.html contains the regees used by this function. The eample valid card numbers are from http://www.paypalobjects.com/en_us/ vhelp/paypalmanager_help/credit_card_numbers.htm Eamples <- c( #visa "4111 1111 1111 1111", #spaces are allowed where they #would occur on the card "4012888888881881", #though they can be omitted "4111 1111 1111 11111", #too many digits "4012888888881882", #bad check digit #mastercard "5555 5555 5555 4444", "5105 1051 0510 5100", "5655 5555 5555 4443", #starts 56 "51051 051 0510 5100", #bad spacing #ame "3782 822463 10005", "3714 496353 98431", "3787 344936 71000", "3782 822463 1005", #not enough digits #diners "3056 930902 5904", "3852 000002 3237", #discover "6011 1111 1111 1117", "6011 0009 9013 9424", #jcb "3530 1113 3330 0000", "3566 0020 2036 0505" is_credit_card_number( assert_any_are_credit_card_numbers( assertive.base::dont_stop(assert_all_are_credit_card_numbers(

assert_all_are_email_addresses 5 assert_all_are_email_addresses Does the character vector contain email addresses? Checks that the input contains email addresses. (It does not check the the address eists, merely that the string is in a suitable format. assert_all_are_email_addresses(, method = c("simple", "rfc5322", = FALSE, assert_any_are_email_addresses(, method = c("simple", "rfc5322", = FALSE, is_email_address(, method = c("simple", "rfc5322" method Name of method to check for validity. See notes below. na.rm in many stats package functions, ecept that the position of the failing A logical vector that is TRUE when the input contains valid email addresses. Each method specifies a regular epression (see rege to match against. The simple method matches most email addresses in use, and is quite good at filtering out typos and nonsense. It won t match every email address however. For eample, emails from a top level domain longer than 4 characters won t pass. The rfc5322 method implements the official standard for emails. Thus all genuine emails will pass, but since the spec is very broad, it isn t as good at filtering out nonsense. References http://www.regular-epressions.info/email.html contains the regees used by this function and a good discussion of the pros and cons of each.

6 assert_all_are_he_colors Eamples addresses <- c( ok = "a@b.com", no_at = "a_at_b.com", no_dot = "a@bcom", long_tld = "a@b.comma", punct = "a!$&@b.com", missing = NA is_email_address(addresses is_email_address(addresses, method = "rfc5322" assert_all_are_he_colors Does the character vector contain he colors? Checks that the input contains headecimal colors. assert_all_are_he_colors(, = FALSE, assert_any_are_he_colors(, = FALSE, assert_all_are_he_colours(, = FALSE, assert_any_are_he_colours(, = FALSE, is_he_color( is_he_colour( na.rm in many stats package functions, ecept that the position of the failing

assert_all_are_honorifics 7 A logical vector that is TRUE when the input contains he colours. A string is considered to represent a headecimal colour when contains a hash followed by si he values. That is, digits or the letters from a to f (case insensitive. Eamples <- c( "#012345", "#789abc", "#defdef", #ok "012345", #no hash "#g12345", #bad letter "#01 23 45", #contains spaces "#12345", "#1234567" #wrong length is_he_color( assert_any_are_he_colors( #These eamples should fail. assertive.base::dont_stop(assert_all_are_he_colors( assert_all_are_honorifics Is the string an honorific? Checks that the input contains honorifics (a.k.a. titles or salutations. assert_all_are_honorifics(, = FALSE, assert_any_are_honorifics(, = FALSE, is_honorific( na.rm in many stats package functions, ecept that the position of the failing

8 assert_all_are_ip_addresses is_honorific returns TRUE if the input string contains a valid UK postcode. The assert_* function returns nothing but throws an error when the is_* function returns FALSE. Single full stops (periods following a word boundary and preceding a space or the end of the string are stripped. Case is ignored. There is no formal list of official salutations, so this should only be used as a guide, rather than giving a definitive result. Especially note that cultural conventions differ across the world and this function has a UK bias. References Many possibilities borrowed from the Salutation dropdown on the MathWorks account creation page. https://www.mathworks.com/accesslogin/createprofile.do Eamples <- c("mr", "MR", "mr.", "Mister", "master", "Mr!", "M.r", ".Mr" is_honorific( assert_all_are_ip_addresses Does the character vector contain IP addresses? Checks that the input contains IP addresses. (It does not check that the address eists, merely that the string is in a suitable format. assert_all_are_ip_addresses(, = FALSE, assert_any_are_ip_addresses(, = FALSE, is_ip_address( na.rm in many stats package functions, ecept that the position of the failing

assert_all_are_isbn_codes 9 A logical vector that is TRUE when the input contains valid IP addresses. Valid IP addresses are considered to be four integers in the range 0 to 255, separated by dots, or the string "localhost". Eamples <- c( localhost = "localhost", valid_address = "255.0.255.0", out_of_range = "1.2.3.256", five_blocks = "1.2.3.4.5", non_numeric = "1.2.3.Z", missing_block = "1.2.3.NA", missing = NA is_ip_address( assert_any_are_ip_addresses( #These eamples should fail. assertive.base::dont_stop(assert_all_are_ip_addresses( assert_all_are_isbn_codes Does the character vector contain ISBN book codes? Checks that the input contains ISBN-10 or ISBN-13 book codes. assert_all_are_isbn_codes(, type = c("10", "13", = FALSE, assert_any_are_isbn_codes(, type = c("10", "13", = FALSE, is_isbn10_code(,.name = get_name_in_parent( is_isbn13_code(,.name = get_name_in_parent( is_isbn_code(, type = c("10", "13"

10 assert_all_are_isbn_codes type.name Either "isbn10", "isbn13" or both (for matching either type. na.rm in many stats package functions, ecept that the position of the failing Not intended to be called directly. A logical vector that is TRUE when the input contains valid ISBN book codes. Eamples 10 <- c( hyphens = "0-387-98503-4", spaces = "0 387 98503 4", just_numbers = "0387985034", too_long = "00-387-98503-4", too_short = "0-387-9850-4", non_numeric = "Z-387-98503-4", invalid_check_digit = "0-387-98503-5", missing = NA 13 <- c( hyphens = "978-0-387-98503-9", spaces = "978 0 387 98503 9", just_numbers = "9780387985039", too_long = "9978-0-387-98503-9", too_short = "978-0-387-9850-9", non_numeric = "Z78-0-387-9850-9", invalid_check_digit = "978-0-387-98503-8", missing = NA is_isbn_code(10, type = "10" assert_any_are_isbn_codes(10, type = "10" is_isbn_code(13, type = "13" assert_any_are_isbn_codes(13, type = "13" #These tests should fail. assertive.base::dont_stop(assert_all_are_isbn_codes(10, type = "10" assertive.base::dont_stop(assert_all_are_isbn_codes(13, type = "13"

Inde assert_all_are_cas_numbers, 2 assert_all_are_credit_card_numbers, 3 assert_all_are_email_addresses, 5 assert_all_are_he_colors, 6 assert_all_are_he_colours (assert_all_are_he_colors, 6 assert_all_are_honorifics, 7 assert_all_are_ip_addresses, 8 assert_all_are_isbn_codes, 9 assert_any_are_cas_numbers (assert_all_are_cas_numbers, 2 assert_any_are_credit_card_numbers (assert_all_are_credit_card_numbers, 3 assert_any_are_email_addresses (assert_all_are_email_addresses, 5 assert_any_are_he_colors (assert_all_are_he_colors, 6 assert_any_are_he_colours (assert_all_are_he_colors, 6 assert_any_are_honorifics (assert_all_are_honorifics, 7 assert_any_are_ip_addresses (assert_all_are_ip_addresses, 8 assert_any_are_isbn_codes (assert_all_are_isbn_codes, 9 is_he_colour (assert_all_are_he_colors, 6 is_honorific (assert_all_are_honorifics, 7 is_ip_address (assert_all_are_ip_addresses, 8 is_isbn10_code (assert_all_are_isbn_codes, 9 is_isbn13_code (assert_all_are_isbn_codes, 9 is_isbn_code (assert_all_are_isbn_codes, 9 rege, 5 is_cas_number (assert_all_are_cas_numbers, 2 is_credit_card_number (assert_all_are_credit_card_numbers, 3 is_email_address (assert_all_are_email_addresses, 5 is_he_color (assert_all_are_he_colors, 6 11