Skip to content

Commit

Permalink
Final fixes before submit to CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
pitkant committed May 20, 2022
1 parent 04671b8 commit 48ce965
Show file tree
Hide file tree
Showing 23 changed files with 107 additions and 107 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: hetu
Type: Package
Title: Structural Handling of Finnish Personal Identity Codes
Version: 1.0.7.9000
Date: 2022-05-16
Version: 1.0.7
Date: 2022-05-20
Authors@R:
c(
person(given = "Pyry",
Expand Down Expand Up @@ -37,7 +37,7 @@ License: BSD_2_clause + file LICENSE
VignetteBuilder: knitr
Encoding: UTF-8
BugReports: https://github.com/ropengov/hetu/issues
URL: https://ropengov.github.io/hetu, https://github.com/ropengov/hetu
URL: https://ropengov.github.io/hetu/, https://github.com/ropengov/hetu
Depends:
R (>= 3.6.0)
Imports:
Expand Down
27 changes: 13 additions & 14 deletions R/hetu.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#' @title Finnish personal identification number extraction
#' @description Extract information from Finnish personal identification
#' numbers (hetu).
#' @param pin Finnish personal identification number as a character vector,
#' or vector of identification numbers as a character vectors
#' @title Generic Extraction Tool for Finnish Personal Identity Codes
#' @description Extract embedded information from Finnish personal identity
#' codes (hetu).
#' @param pin Finnish personal identity code(s) as a character vector
#' @param extract Extract only selected part of the information.
#' Valid values are "\code{hetu}", "\code{sex}", "\code{p.num}",
#' "\code{ctrl.char}", "\code{date}", "\code{day}", "\code{month}",
Expand All @@ -16,28 +15,28 @@
#' "\code{correct.ctrl.char}", "\code{valid.date}", "\code{valid.day}",
#' "\code{valid.month}", "\code{valid.length}", "\code{valid.century}".
#' Default is \code{FALSE} which returns no diagnostic information.
#' @return Finnish personal identification number data.frame,
#' @return Finnish personal identity code data.frame,
#' or if extract parameter is set, the requested part of the
#' information as a vector. Returns an error or \code{NA} if the given
#' character vector is not a valid Finnish personal identification number.
#' \item{hetu}{Finnish personal identification number as a character vector.
#' character vector is not a valid Finnish personal identity code.
#' \item{hetu}{Finnish personal identity code as a character vector.
#' A correct pin should be in the form DDMMYYCZZZQ, where DDMMYY stands for
#' date, C for century sign, ZZZ for personal number and Q for control
#' character.}
#' \item{sex}{sex of the person as a character vector ("Male" or "Female").}
#' \item{p.num}{Personal number part of the identification number.}
#' \item{ctrl.char}{Control character for the personal identification number.}
#' \item{p.num}{Personal number part of the identity code.}
#' \item{ctrl.char}{Control character for the personal identity code.}
#' \item{date}{Birthdate.}
#' \item{day}{Day of the birthdate.}
#' \item{month}{Month of the birthdate.}
#' \item{year}{Year of the birthdate.}
#' \item{century}{Century character of the birthdate: + (1800), - (1900) or
#' A (2000).}
#' \item{valid.pin}{Does the personal identification number pass all validity
#' \item{valid.pin}{Does the personal identity code pass all validity
#' checks: (\code{TRUE} or \code{FALSE})}
#' @author Pyry Kantanen, Jussi Paananen
#' @seealso \code{\link{pin_ctrl}} For validating Finnish personal
#' identification numbers.
#' identity codes.
#' @examples
#' hetu("111111-111C")
#' hetu("111111-111C")$date
Expand Down Expand Up @@ -126,7 +125,7 @@ hetu <- function(pin, extract = NULL, allow.temp = FALSE, diagnostic = FALSE) {
names(checklist) <- 0:30
valid_ctrl_char_test <- extracted_ctrl_char %in% checklist

# Get personal identification number
# Get personal identity code
extracted_personal_number <- substr(pin, start = 8, stop = 10)
extracted_personal_number <- formatC(extracted_personal_number,
width = 3, format = "d", flag = "0")
Expand All @@ -143,7 +142,7 @@ hetu <- function(pin, extract = NULL, allow.temp = FALSE, diagnostic = FALSE) {
extracted_sex <- ifelse(((as.numeric(extracted_personal_number) %% 2) == 0),
"Female", "Male")

# Check if personal identification number is artificial or temporary
# Check if personal identity code is artificial or temporary
is_temp_test <- as.numeric(extracted_personal_number) >= 900

# Check pin number of characters
Expand Down
6 changes: 3 additions & 3 deletions R/hetu_control_char.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @title Finnish Personal Identification Number Control Character Calculator
#' @title Calculate Control Character for Personal Identity Code
#' @description Calculate a valid control character for an incomplete
#' Finnish personal identification numbers (hetu).
#' Finnish personal identity codes (hetu).
#' @param pin An incomplete PIN that ONLY has a date, century marker (optional,
#' see parameter with.century) and personal number
#' @param with.century If TRUE (default), the function assumes that the PIN
Expand All @@ -19,7 +19,7 @@
#' @return Control character, either a number 0-9 or a letter.
#' @author Pyry Kantanen
#' @seealso \code{\link{hetu}} For extracting information from Finnish personal
#' identification numbers.
#' identity codes.
#' @examples
#' hetu_control_char("010101-010")
#' hetu_control_char("010101010", with.century = FALSE)
Expand Down
7 changes: 5 additions & 2 deletions R/hetu_diagnostic.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## hetu_diagnostic.R
#' @title Diagnostics Tool for HETU
#' @description Produce a data frame of PINs that may require closer scrutiny.
#' @title Diagnostics Tool for Personal Identity Codes
#' @description Prints information on the tests that are used
#' to confirm or reject the validity of each personal identity code.
#' @param pin Finnish personal identification number as a character vector,
#' or vector of identification numbers as a character vectors
#' @param extract Extract only selected part of the diagnostic information.
Expand All @@ -17,6 +18,8 @@
#' hetu_diagnostic(diagnosis_example)
#' # Extract century-related checks
#' hetu_diagnostic(diagnosis_example, extract = "valid.century")
#' @seealso \code{\link{hetu}} for the main function on which
#' \code{hetu_diagnostic} relies on.
#'
#' @export
hetu_diagnostic <- function(pin, extract = NULL) {
Expand Down
5 changes: 3 additions & 2 deletions R/pin_age.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' @title Age from ID
#' @description Calculate the age in full years for a given date.
#' @title Extract Age from Personal Identity Code
#' @description Calculate age in years, months, weeks or days from
#' personal identity codes.
#' @inheritParams hetu
#' @param date Date at which age is calculated. If a vector is provided it
#' must be of the same length as the \code{pin} argument.
Expand Down
13 changes: 6 additions & 7 deletions R/pin_ctrl.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#' @title Finnish Personal Identification Number Validator
#' @description Validate Finnish personal identification numbers (hetu).
#' @param pin Finnish personal identification number as a character vector, or
#' vector of identification numbers as a character vectors.
#' @title Check Validity of Personal Identity Code
#' @description Validate Finnish personal identity codes (hetu).
#' @param pin Finnish personal identity code(s) as a character vector
#' @param allow.temp If TRUE, temporary PINs (personal numbers 900-999) are
#' handled similarly to regular PINs (personal numbers 002-899), meaning
#' that otherwise valid temporary PIN will return a TRUE. Default
Expand All @@ -10,7 +9,7 @@
#' Finnish personal identity codes.
#' @author Pyry Kantanen
#' @seealso \code{\link{hetu}} For extracting information from Finnish personal
#' identification numbers.
#' identity codes.
#' @examples
#' pin_ctrl("010101-0101") # TRUE
#' pin_ctrl("010101-010A") # FALSE
Expand All @@ -31,7 +30,7 @@ pin_ctrl <- function(pin, allow.temp = FALSE) {
#' @export
hetu_ctrl <- pin_ctrl

#' @title Check Finnish Business ID (y-tunnus) validity
#' @title Check Validity of Finnish Business ID (Y-tunnus)
#'
#' @description
#' A function that checks whether a \code{bid} (Finnish Business ID) is valid.
Expand Down Expand Up @@ -100,7 +99,7 @@ bid_ctrl <- function(bid) {
return(check)
}

#' @title Check Finnish Unique Identification Number validity
#' @title Check Validity of Finnish Unique Identification Number (SATU)
#'
#' @description
#' A function that checks whether a \code{satu} (Finnish Unique Identification
Expand Down
4 changes: 2 additions & 2 deletions R/pin_date.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @title Get Birth date from PIN
#' @description Calculates the date of birth in date format.
#' @title Extract Date of Birth from Personal Identity Code
#' @description Returns the date of birth in date format.
#' @inheritParams hetu
#' @return Date of birth as a vector in date format.
#' @examples
Expand Down
5 changes: 3 additions & 2 deletions R/pin_sex.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' @title Sex From ID
#' @description Extract sex from Finnish personal identification number.
#' @title Extract Sex from Personal Identity Code
#' @description Extract sex (as binary) from Finnish personal identification
#' code.
#' @inheritParams hetu
#' @return Factor with label 'Male' and 'Female'.
#' @author Pyry Kantanen, Leo Lahti
Expand Down
7 changes: 4 additions & 3 deletions R/rpin.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @title Generate a vector of random \code{hetu}
#' @title Generate Random Personal Identity Codes
#'
#' @description
#' A function that generates random \code{hetu}-pins.
#' A function that generates random Finnish personal identity codes
#' (\code{hetu} codes).
#'
#' @details
#' There is a finite number of valid personal identity codes available per day.
Expand Down Expand Up @@ -125,7 +126,7 @@ rpin <- function(n,
#' @export
rhetu <- rpin

#' @title Generate a vector of random Finnish Business ID's (y-tunnus)
#' @title Generate Random Finnish Business ID's (Y-tunnus)
#'
#' @description
#' A function that generates random Finnish Business ID's, \code{bid}-numbers
Expand Down
16 changes: 8 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ knitr::opts_chunk$set(
<!-- README.md is generated from README.Rmd. Please edit that file -->

<!-- badges: start -->
[![rOG-badge](https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg)](http://ropengov.org/)
[![rOG-badge](https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg)](https://ropengov.org/)
[![R build status](https://github.com/rOpenGov/hetu/workflows/R-CMD-check/badge.svg)](https://github.com/rOpenGov/hetu/actions)
[![codecov](https://codecov.io/gh/rOpenGov/hetu/branch/master/graph/badge.svg)](https://codecov.io/gh/rOpenGov/hetu)
[![codecov](https://codecov.io/gh/rOpenGov/hetu/branch/master/graph/badge.svg)](https://app.codecov.io/gh/rOpenGov/hetu)
[![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/hetu)](https://cran.r-project.org/package=hetu)
[![Downloads](http://cranlogs.r-pkg.org/badges/hetu)](https://cran.r-project.org/package=hetu)
[![Watch on GitHub][github-watch-badge]][github-watch]
[![Star on GitHub][github-star-badge]][github-star]
[![Follow](https://img.shields.io/twitter/follow/ropengov.svg?style=social)](https://twitter.com/intent/follow?screen_name=ropengov)
[![cran version](http://www.r-pkg.org/badges/version/hetu)](http://cran.rstudio.com/web/packages/hetu)
[![cran version](http://www.r-pkg.org/badges/version/hetu)](https://CRAN.R-project.org/package=hetu)
<!-- badges: end -->

<!--[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/grand-total/hetu)](https://github.com/metacran/cranlogs.app)-->
Expand All @@ -30,9 +30,9 @@ knitr::opts_chunk$set(

### Introduction

`hetu` is an R package for structural handling of national identification numbers used in Finland, or more specifically Finnish personal identity codes (in Finnish: henkilötunnus (hetu), in Swedish: personbeteckning). Some functions can also be used with Finnish Business ID numbers (y-tunnus).
`hetu` is an R package for structural handling of identification codes used in Finland, most importantly Finnish flavour of national identification numbers, the Finnish personal identity codes (in Finnish: henkilötunnus (hetu), in Swedish: personbeteckning). Some functions can also be used with Finnish Business ID numbers (in Finnish: yritys- ja yhteisötunnus (y-tunnus), in Swedish: företags- och organisationsnummer (FO-nummer)) and Finnish Unique Identification Numbers (FINUID, in Finnish: sähköinen asiointitunnus (SATU), in Swedish: elektronisk kommunikationskod).

The syntax in this package is unified with the similar package for Swedish ID numbers, the [sweidnumbr](https://github.com/rOpenGov/sweidnumbr).
The syntax in this package aims to be, when convenient, similar with another package specializing in national identification numbers: the [sweidnumbr](https://github.com/rOpenGov/sweidnumbr) R package for working with Swedish personal identity numbers and corporation identity numbers.

### Installation

Expand Down Expand Up @@ -93,13 +93,13 @@ vignette("hetu")
* [Submit suggestions and bug reports](https://github.com/ropengov/hetu/issues) (provide the output of `sessionInfo()` and `packageVersion("hetu")` and preferably provide a [reproducible example](http://adv-r.had.co.nz/Reproducibility.html))
* [Send a pull request](https://github.com/rOpenGov/hetu/pulls)
* [Star us on the Github page](https://github.com/ropengov/hetu/)
* [See our website](http://ropengov.org/community/) for additional contact information
* [See our website](https://ropengov.org/community/) for additional contact information

## Acknowledgements

**Kindly cite this work** as follows: [Pyry Kantanen](http://github.com/pitkant/), Måns Magnusson, Jussi Paananen, Leo Lahti. hetu: Finnish personal ID number data toolkit for R. URL: [http://ropengov.github.io/hetu/](http://ropengov.github.io/hetu/)
**Kindly cite this work** as follows: [Pyry Kantanen](https://github.com/pitkant/), Måns Magnusson, Jussi Paananen, Leo Lahti. hetu: Finnish personal ID number data toolkit for R. URL: [https://ropengov.github.io/hetu/](https://ropengov.github.io/hetu/)

We are grateful to all [contributors](https://github.com/rOpenGov/hetu/graphs/contributors)! This project is part of [rOpenGov](http://ropengov.org).
We are grateful to all [contributors](https://github.com/rOpenGov/hetu/graphs/contributors)! This project is part of [rOpenGov](https://ropengov.org).

[github-watch-badge]: https://img.shields.io/github/watchers/ropengov/hetu.svg?style=social
[github-watch]: https://github.com/ropengov/hetu/watchers
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

<!-- badges: start -->

[![rOG-badge](https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg)](http://ropengov.org/)
[![rOG-badge](https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg)](https://ropengov.org/)
[![R build
status](https://github.com/rOpenGov/hetu/workflows/R-CMD-check/badge.svg)](https://github.com/rOpenGov/hetu/actions)
[![codecov](https://codecov.io/gh/rOpenGov/hetu/branch/master/graph/badge.svg)](https://codecov.io/gh/rOpenGov/hetu)
[![codecov](https://codecov.io/gh/rOpenGov/hetu/branch/master/graph/badge.svg)](https://app.codecov.io/gh/rOpenGov/hetu)
[![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/hetu)](https://cran.r-project.org/package=hetu)
[![Downloads](http://cranlogs.r-pkg.org/badges/hetu)](https://cran.r-project.org/package=hetu)
[![Watch on
Expand All @@ -15,7 +14,7 @@ GitHub](https://img.shields.io/github/watchers/ropengov/hetu.svg?style=social)](
GitHub](https://img.shields.io/github/stars/ropengov/hetu.svg?style=social)](https://github.com/ropengov/hetu/stargazers)
[![Follow](https://img.shields.io/twitter/follow/ropengov.svg?style=social)](https://twitter.com/intent/follow?screen_name=ropengov)
[![cran
version](http://www.r-pkg.org/badges/version/hetu)](http://cran.rstudio.com/web/packages/hetu)
version](http://www.r-pkg.org/badges/version/hetu)](https://CRAN.R-project.org/package=hetu)
<!-- badges: end -->

<!--[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/grand-total/hetu)](https://github.com/metacran/cranlogs.app)-->
Expand Down Expand Up @@ -101,23 +100,23 @@ vignette("hetu")

## Contributing

- [Submit suggestions and bug
- [Submit suggestions and bug
reports](https://github.com/ropengov/hetu/issues) (provide the
output of `sessionInfo()` and `packageVersion("hetu")` and
preferably provide a [reproducible
example](http://adv-r.had.co.nz/Reproducibility.html))
- [Send a pull request](https://github.com/rOpenGov/hetu/pulls)
- [Star us on the Github page](https://github.com/ropengov/hetu/)
- [See our website](http://ropengov.org/community/) for additional
- [Send a pull request](https://github.com/rOpenGov/hetu/pulls)
- [Star us on the Github page](https://github.com/ropengov/hetu/)
- [See our website](https://ropengov.org/community/) for additional
contact information

## Acknowledgements

**Kindly cite this work** as follows: [Pyry
Kantanen](http://github.com/pitkant/), Måns Magnusson, Jussi Paananen,
Kantanen](https://github.com/pitkant/), Måns Magnusson, Jussi Paananen,
Leo Lahti. hetu: Finnish personal ID number data toolkit for R. URL:
<http://ropengov.github.io/hetu/>
<https://ropengov.github.io/hetu/>

We are grateful to all
[contributors](https://github.com/rOpenGov/hetu/graphs/contributors)\!
This project is part of [rOpenGov](http://ropengov.org).
[contributors](https://github.com/rOpenGov/hetu/graphs/contributors)!
This project is part of [rOpenGov](https://ropengov.org).
13 changes: 4 additions & 9 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
## Test environments
* local macOS 10.15.7 install, R 4.0.3
* ubuntu 20.04, R 4.0.0

* local macOS 12.4 install (Intel 64-bit), R 4.2.0
* win-builder (devel and release)
* R-CMD-check workflow (macOS-latest, windows-latest, ubuntu-latest-devel, ubuntu-latest-release, ubuntu-latest-oldrel-1)

## R CMD check results
There were no ERRORs or WARNINGs.

There was 1 NOTE:

* checking CRAN incoming feasibility ... NOTE
Maintainer: ‘Pyry Kantanen <[email protected]>’

New submission
There were no ERRORs or WARNINGs.

## Downstream dependencies

Expand Down
2 changes: 1 addition & 1 deletion man/bid_ctrl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 48ce965

Please sign in to comment.