Getting Started with fkr

library(fkr)

What does this package do?

fkr makes pretend (fake) data that looks like it came from the Philippines – names, addresses, phone numbers, ages, job titles, and more – without using any real person’s information.

Why would you want “fake” data?

Every single value this package produces – every name, every address, every number – is made up on the spot. Nothing is looked up from a real database of real people.

A note on ID numbers. Some functions produce values formatted to look like Philippine government ID numbers (an SSS number, a TIN, a PhilSys number, and so on). These are entirely random digits arranged in the right pattern – they are not real ID numbers, they don’t belong to anyone, and they will not work if you try to use them anywhere official. They exist only so that test data looks complete.

Installing fkr

If this is your first time, you’ll need R installed on your computer (see r-project.org). Once R is running, install fkr with:

# install.packages("devtools")
pak::pak("yng-me/fkr")

Then, every time you want to use it, start your R session with:

library(fkr)

Your first fake value

Every function in this package starts with fkr_, so they’re easy to spot and to search for. Let’s make one fake first name:

fkr_first_name(1)
#> [1] "Linda"

That 1 tells the function “I want one value.” Want five instead? Change the 1 to a 5:

fkr_first_name(5)
#> [1] "Tyson"    "Vienna"   "Hagibis"  "Paulina"  "Benedict"

That’s the pattern for everything in this package: the first thing you tell a fkr_* function is always how many fake values you want.

fkr_age(5)
#> [1] 45  2 18 18 19
fkr_boolean(5)
#> [1] FALSE FALSE FALSE FALSE  TRUE
fkr_civil_status(5)
#> [1] "Single"  "Married" "Single"  "Married" "Single"

A quick tour of what you can generate

People

fkr_first_name(3)
#> [1] "Petra" "Carla" "Gwen"
fkr_last_name(3)
#> [1] "Perez"    "Agcaoili" "Bernardo"
fkr_full_name(3)
#> [1] "Zaida Dela Cruz" "Wilmer Chua"     "Julia Rodriguez"
fkr_sex(3)
#> [1] "Female" "Female" "Male"
fkr_civil_status(3)
#> [1] "Married" "Married" "Married"
fkr_age(3)
#> [1] 23 39  0
fkr_birthday(3)
#> [1] "2009-02-13" "2019-01-12" "1973-02-02"

Contact details

fkr_email(3)
#> [1] "ryan.evangelista@gmail.com" "demetria.ramos84@gmail.com"
#> [3] "caroline.dizon@yahoo.com"
fkr_mobile_number(3)
#> [1] "09980004156" "08971267039" "09479303194"
fkr_landline_number(3)
#> [1] "(082) 657 7777" "(045) 620 7180" "(045) 018 3761"

Addresses and places in the Philippines

fkr_region(3)
#> [1] "Region XI (Davao Region)"                               
#> [2] "Bangsamoro Autonomous Region In Muslim Mindanao (BARMM)"
#> [3] "Region II (Cagayan Valley)"
fkr_province(3)
#> [1] "Biliran"        "Agusan del Sur" "La Union"
fkr_city(3)
#> [1] "Valenzuela"   "San Juan"     "Balanga City"
fkr_barangay(3)
#> [1] "Bayanihan"     "Tibig"         "Santo Domingo"
fkr_street_address(3)
#> [1] "406 Aguinaldo Extension"   "797 Luna Extension"       
#> [3] "285 Shaw Boulevard Street"

Need a full, ready-made address (street, barangay, city, province, region, and ZIP code, all matching each other)? There’s a function for that too, and it gives you back a small table instead of a single value:

fkr_address(3)
#>                            street  barangay          city province
#> 1 371 Maharlika Highway Extension Guadalupe Tacloban City    Leyte
#> 2                908 Rizal Street   Lourdes Batangas City Batangas
#> 3                97 Roxas Highway  Masagana   Tarlac City   Tarlac
#>                          region  zip
#> 1 Region VIII (Eastern Visayas) 6500
#> 2      Region IV-A (CALABARZON) 4200
#> 3    Region III (Central Luzon) 2300

Government ID-style numbers

As mentioned above, these are random digits in the right pattern – not real IDs.

fkr_sss_number(3)
#> [1] "24-0408070-3" "13-0391364-7" "84-2163396-9"
fkr_tin_number(3)
#> [1] "477-192-248-409" "837-675-610-847" "123-727-430-641"
fkr_philhealth_number(3)
#> [1] "49-165374551-4" "80-025866443-4" "12-545020378-3"
fkr_pagibig_number(3)
#> [1] "4683-3389-5065" "7353-7559-3265" "8963-8317-0288"
fkr_philsys_number(3)
#> [1] "4269-5494-6578-2354" "9669-6166-7915-3672" "7955-7865-9480-7767"

Businesses and jobs

fkr_company(3)
#> [1] "Ancheta Agro-Industrial Ltd."   "Perez & Garcia Consultancy OPC"
#> [3] "Frias & Garcia Trading OPC"
fkr_job_title(3)
#> [1] "Bank Teller"            "Barangay Captain"       "Barangay Health Worker"
fkr_industry(3)
#> [1] "Manufacturing" "Real Estate"   "Fisheries"
fkr_product(3)
#> [1] "Rubber Tsinelas"     "Barako Coffee Beans" "Banana Chips"
fkr_price(3)
#> [1] "PHP 6,760.56" "PHP 1,141.17" "PHP 5,140.97"

Small, general-purpose helpers

These aren’t Philippines-specific – they’re handy building blocks for any fake dataset.

fkr_num(5, min = 0, max = 100)          # plain numbers, e.g. a score or a rating
#> [1] 12.09 27.69  0.37 56.73 27.00
fkr_int(5, min = 18, max = 65)          # whole numbers, e.g. an age range
#> [1] 53 52 59 47 31
fkr_boolean(5)                          # TRUE / FALSE, e.g. "has a Facebook account?"
#> [1] FALSE  TRUE FALSE  TRUE FALSE
fkr_uuid(3)                             # a unique ID for each record
#> [1] "9c18cab6-230a-4c57-9f23-25b05f086a6d"
#> [2] "2befa218-70b3-449f-9e53-c4aafb5a7e0f"
#> [3] "639fec25-48b2-4348-a4fe-05a7ddc683fb"

Two more worth a closer look:

fkr_multiple_response() pretends to be a survey question where someone can pick more than one answer (a “select all that apply” question):

fkr_multiple_response(5, values = c("Email", "Phone", "SMS"), sep = ", ")
#> [1] "Phone, SMS"        "Email, Phone, SMS" "Email"            
#> [4] "Email, SMS"        "Email, Phone, SMS"

fkr_factor() creates a fake category column, where each code has a friendlier label attached – similar to how survey or statistics software lets you store 1/2 but display “Male”/“Female”:

fkr_factor(5, values = c(1, 2), labels = c("Male", "Female"))
#> [1] Male   Male   Male   Male   Female
#> Levels: Male Female

You can also attach a short description of the whole column (not each value) using label:

sex <- fkr_factor(
  5,
  values = c(1, 2), labels = c("Male", "Female"),
  label = "Respondent's biological sex"
)
sex
#> [1] Male   Male   Male   Female Male  
#> attr(,"label")
#> [1] Respondent's biological sex
#> Levels: Male Female
attr(sex, "label")
#> [1] "Respondent's biological sex"

Building a whole pretend dataset at once

So far we’ve made one column at a time. Most of the time, though, you want a whole table of fake data – like a spreadsheet with many columns and many rows, where each row is one pretend person or one pretend record.

That’s what the fkr() function is for. You give it:

  1. n: how many rows (pretend people) you want, and
  2. specs: a list that says, for each column, which fkr_* function should fill it in.
fkr(5, list(
  first_name = fkr_first_name,
  last_name = fkr_last_name,
  sex = fkr_sex,
  age = fkr_age,
  date_of_birth = fkr_birthday,
  mobile_number = fkr_mobile_number
))
#>   first_name  last_name    sex age date_of_birth mobile_number
#> 1  Estefania  Pamintuan Female  27    1999-03-19   09491636431
#> 2     Jayden     Garcia   Male   8    2017-12-30   09503559965
#> 3      Roger      Ramos   Male  44    1982-08-31   09451702197
#> 4   Clarissa    Navarro   Male   4    2022-05-25   09555953229
#> 5  Benedicta Villanueva Female  43    1983-05-15   09394930211

Notice that we wrote fkr_first_name, not fkr_first_name() – no parentheses. We’re telling fkr() which tool to use for that column; it takes care of calling it the right number of times for you.

If a column’s generator gives back a whole mini-table of its own – like fkr_address() does – fkr() automatically spreads its pieces out into separate columns, named after the column you asked for:

fkr(3, list(
  name = fkr_full_name,
  address = fkr_address
))
#>             name        address_street address_barangay address_city
#> 1   Roman Garcia 504 Commonwealth Road        Katipunan  Baguio City
#> 2    Lukas Reyes  302 Del Pilar Street         Masagana Dagupan City
#> 3 Mars Barcelona 3 Commonwealth Avenue      San Vicente Bayugan City
#>   address_province                         address_region address_zip
#> 1          Benguet Cordillera Administrative Region (CAR)        2600
#> 2       Pangasinan               Region I (Ilocos Region)        2400
#> 3   Agusan del Sur                   Region XIII (Caraga)        8502

Fixing extra settings for a column

Some generators accept extra settings. For example, fkr_city() can be limited to one province. To use that inside fkr(), wrap it in a small “recipe”:

fkr(5, list(
  city_in_cebu = function(n) fkr_city(n, province = "Cebu")
))
#>   city_in_cebu
#> 1    Cebu City
#> 2 Mandaue City
#> 3 Mandaue City
#> 4 Mandaue City
#> 5 Mandaue City

Read function(n) fkr_city(n, province = "Cebu") as: “to make this column, call fkr_city, asking for n values, always from the province of Cebu.”

Making one column depend on another

Sometimes a column’s value should depend on another column you already made – for example, whether someone is a “Minor” or an “Adult” depends on their age. Add a second ingredient, data, to see the columns built so far:

fkr(6, list(
  age = fkr_age,
  stage = function(n, data) ifelse(data$age < 18, "Minor", "Adult")
))
#>   age stage
#> 1   3 Minor
#> 2  14 Minor
#> 3  14 Minor
#> 4  43 Adult
#> 5   2 Minor
#> 6  40 Adult

Keeping an age and a birthday that agree with each other

If you ask for both an age column and a birthday column in the same fkr() call, fkr is smart about it: it makes sure the birthday it generates actually matches the age in that same row. You don’t have to do anything extra – just ask for both, by name, as shown below:

people <- fkr(5, list(
  age = fkr_age,
  date_of_birth = fkr_birthday
))
people
#>   age date_of_birth
#> 1   3    2023-05-14
#> 2  26    1999-11-23
#> 3  92    1934-02-21
#> 4  22    2004-04-26
#> 5   1    2025-04-08

(If you ever want them to be unrelated – unusual, but possible – wrap one of them in function(n) ..., the same trick shown above for “extra settings.” That tells fkr you’re taking manual control of that column.)

Making your “random” results repeatable

Everything in this package is random by design – that’s the point of fake data! But sometimes you want to get the exact same fake data again, for example to write a tutorial where your readers see the same numbers you did.

Call fkr_seed() with any whole number right before generating your data:

fkr_seed(2024)
fkr_first_name(3)
#> [1] "Sebastian" "Zach"      "Severina"

fkr_seed(2024)
fkr_first_name(3) # identical to the line above
#> [1] "Sebastian" "Zach"      "Severina"

Where to go next