### Install sweidnumbr from GitHub Source: http://ropengov.github.io/sweidnumbr/index.html Install the latest development version of the sweidnumbr package from GitHub using the devtools package. Load the library after installation. ```r devtools::install_github("rOpenGov/sweidnumbr") library(sweidnumbr) ``` -------------------------------- ### Install sweidnumbr from CRAN Source: http://ropengov.github.io/sweidnumbr/index.html Use this command to install the sweidnumbr package from the Comprehensive R Archive Network (CRAN). ```r install.packages(sweidnumbr) ``` -------------------------------- ### View sweidnumbr Vignette Source: http://ropengov.github.io/sweidnumbr/index.html Access the tutorial and detailed usage guide for the sweidnumbr package by viewing its vignette. ```r vignette("sweidnumbr") ``` -------------------------------- ### Load sweidnumbr Library Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Load the sweidnumbr library into the R session after installation. ```r library(sweidnumbr) ``` -------------------------------- ### Get sweidnumbr Package Citation Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Retrieve the citation information for the sweidnumbr R package, including author, year, and URL, for academic or formal referencing. ```r citation("sweidnumbr") ``` -------------------------------- ### Retrieve R Session Information Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Displays the current R session environment, including loaded packages and system locale settings. ```R sessionInfo() ``` -------------------------------- ### Format PIN for Presentation Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Format personal identity numbers into various string representations using the `format_pin()` function. Note that the output is a character vector, not a `pin` object. ```r format_pin(example_pin, "%Y-%m-%d-%N") ``` ```r format_pin(example_pin, "%P") ``` -------------------------------- ### Extract Birthplace from PIN Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Retrieve the birthplace information for personal identity numbers using the `pin_birthplace()` function. The output includes county and municipality details. ```r pin_birthplace(example_pin) ``` -------------------------------- ### Set UTF-8 Encoding Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Set the system locale to UTF-8 encoding, which is recommended for handling character data. ```r Sys.setlocale(locale="UTF-8") ``` -------------------------------- ### Utility and Generation Functions Source: http://ropengov.github.io/sweidnumbr/reference/index.html Helper functions for generating random numbers, checking control digits, and performing algorithmic validation. ```APIDOC ## rpin() ### Description Generate a vector of random personal identity numbers. ## roin() ### Description Generate a vector of random organizational identity numbers. ## luhn_algo() ### Description The Luhn algorithm implementation for validation. ## pin_ctrl() ### Description Check control number from a PIN. ``` -------------------------------- ### Convert and Standardize Personal Identity Numbers (PINs) Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Convert character strings representing personal identity numbers (PINs) into a standardized format using the `as.pin()` function. This function handles different input formats and ensures consistency. ```r example_pin <- c("640823-3234", "6408233234", "19640823-3230") example_pin <- as.pin(example_pin) example_pin ``` -------------------------------- ### Calculate Age from PIN (Specific Date) Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Calculate the age of individuals based on their personal identity numbers relative to a specified date. Use the `date` argument in the `pin_age()` function. ```r pin_age(example_pin, date = "2000-01-01") ``` -------------------------------- ### Calculate Age from PIN (Current Date) Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Calculate the age of individuals based on their personal identity numbers using the current date as the reference. The `pin_age()` function returns the age in years. ```r pin_age(example_pin) ``` -------------------------------- ### Extract Sex from PIN Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Determine the sex associated with personal identity numbers using the `pin_sex()` function. The output is a factor with 'Male' as a level. ```r pin_sex(example_pin) ``` -------------------------------- ### Convert and Standardize Organizational Identity Numbers (OINs) Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Convert character strings representing organizational identity numbers (OINs) into a standardized format using the `as.oin()` function. OINs have a specific required format. ```r example_oin <- c("556000-4615", "232100-0156", "802002-4280") example_oin <- as.oin(example_oin) example_oin ``` -------------------------------- ### Generate Random Personal Identity Numbers (PINs) Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Generate random personal identity numbers using the `rpin()` function. This is useful for testing or creating sample data. ```r rpin(3) ``` -------------------------------- ### Check if a Vector is a PIN Object Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Use the `is.pin()` function to verify if a vector contains personal identity numbers formatted correctly. ```r is.pin(example_pin) ``` -------------------------------- ### Check if a Vector is an OIN Object Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Use the `is.oin()` function to verify if a vector contains organizational identity numbers formatted correctly. ```r is.oin(example_oin) ``` -------------------------------- ### Generate Random Organizational Identity Numbers (OINs) Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Generate random organizational identity numbers using the `roin()` function. This is useful for testing or creating sample data. ```r roin(3) ``` -------------------------------- ### Validate PIN Control Number Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Validate personal identity numbers using their control digits with the `pin_ctrl()` function. It returns TRUE for valid numbers and FALSE for invalid ones. ```r pin_ctrl(example_pin) ``` -------------------------------- ### PIN Data Extraction Source: http://ropengov.github.io/sweidnumbr/reference/index.html Functions to extract demographic information from valid Swedish personal identity numbers. ```APIDOC ## pin_age() ### Description Calculate age of a PIN for a given date. ## pin_birthplace() ### Description Calculate the birthplace of a PIN. ## pin_date() ### Description Calculate the date of birth from a PIN. ## pin_sex() ### Description Calculate sex from a PIN. ``` -------------------------------- ### Identity Number Parsing and Validation Source: http://ropengov.github.io/sweidnumbr/reference/index.html Functions for parsing, testing, and formatting Swedish personal and organizational identity numbers. ```APIDOC ## as.pin() ### Description Parse personal identity numbers to ABS format. ## is.pin() ### Description Test if a character vector contains correct personal identity numbers. ## as.oin() ### Description Parse organizational identity numbers. ## is.oin() ### Description Test if a character vector contains correct organizational identity numbers. ``` -------------------------------- ### Determine Organization Type from OIN Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Categorize organizational identity numbers based on the type of organization they represent using the `oin_group()` function. This function returns descriptive labels for each OIN. ```r oin_group(example_oin) ``` -------------------------------- ### Validate OIN Control Number Source: http://ropengov.github.io/sweidnumbr/articles/sweidnumbr.html Validate organizational identity numbers using their control digits with the `oin_ctrl()` function. It returns TRUE for valid numbers. ```r oin_ctrl(example_oin) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.