sweidnumbr : Structural handling of swedish identity numbers

This R package provides tools to work with swedish identity numbers such as personal identity numbers (personnummer) and organizational identity numbers (organisationsnummer).

Table of contents

Installation (Installation)
Examples (Examples)
References (References)

Installation

Install the stable release version in R:

install.packages("sweidnumbr")

Test the installation by loading the library:

library(sweidnumbr)

We also recommend setting the UTF-8 encoding:

Sys.setlocale(locale="UTF-8") 

Examples

As a first step we need to convert personal identity numbers (pin) to the sam standard ABS format.

example_pin <- c("640823-3234", "6408233234", "19640823-3230")
example_pin <- pin_format(example_pin)
example_pin
## [1] "196408233234" "196408233234" "196408233230"

The next step is to test if the format is correct. To do this we use the is_pin() function.

is.pin(example_pin)
## [1] TRUE TRUE TRUE

This only check the format of the pin. To check the pin using the control number we use pin_ctrl().

pin_ctrl(example_pin)
## [1]  TRUE  TRUE FALSE

We can now use pin_birthplace() and pin_sex(). To get information on sex and birthplace.

pin_sex(example_pin)
## [1] Male Male Male
## Levels: Male
pin_birthplace(example_pin)
## [1] Gotlands län Gotlands län Gotlands län
## Levels: Gotlands län

As the last step we can calculate the age based on the pin. We choose the date where we want to calculate the age. If date is not specified the current date is used.

pin_age(example_pin)
## [1] 50 50 50
pin_age(example_pin, date = "2000-01-01")
## [1] 35 35 35

Licensing and Citations

This work can be freely used, modified and distributed under the open license specified in the DESCRIPTION file.

Kindly cite the work as follows

citation("sweidnumbr")
## 
## Kindly cite the sweidnumbr R package as follows:
## 
##   (C) Mans Magnusson(2014).  sweidnumbr: R tools to handle of
##   swedish identity numbers. URL:
##   http://github.com/MansMeg/sweidnumbr
## 
## A BibTeX entry for LaTeX users is
## 
##   @Misc{,
##     title = {sweidnumbr: R tools to handle of swedish identity numbers.},
##     author = {Mans Magnusson},
##     year = {2014},
##   }

Session info

This vignette was created with

sessionInfo()
## R version 3.1.0 (2014-04-10)
## Platform: x86_64-apple-darwin13.1.0 (64-bit)
## 
## locale:
## [1] sv_SE.UTF-8/sv_SE.UTF-8/sv_SE.UTF-8/C/sv_SE.UTF-8/sv_SE.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] lubridate_1.3.3 sweidnumbr_0.1 
## 
## loaded via a namespace (and not attached):
##  [1] digest_0.6.4     evaluate_0.5.5   formatR_0.10     htmltools_0.2.4 
##  [5] knitr_1.6        memoise_0.2.1    plyr_1.8.1       Rcpp_0.11.1     
##  [9] rmarkdown_0.2.64 stringr_0.6.2    tools_3.1.0      yaml_2.1.13