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?

  • You’re building an app or a form and want to see what it looks like with data in it, before any real user has signed up.
  • You’re teaching a class or writing a tutorial and need realistic-looking example data, without handing out anyone’s real details.
  • You’re testing software: trying it with 10,000 pretend customers is much safer (and easier) than testing with real ones.

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] "Tyler"

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

fkr_first_name(5)
#> [1] "Gemma"    "Ruth"     "Penelope" "Jezebel"  "Ike"

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]  8 11  1 11  0
fkr_boolean(5)
#> [1]  TRUE FALSE  TRUE  TRUE  TRUE
fkr_civil_status(5)
#> [1] "Single"    "Single"    "Separated" "Single"    "Married"

A quick tour of what you can generate

People

fkr_first_name(3)
#> [1] "Sol"     "Omarion" "Tahira"
fkr_last_name(3)
#> [1] "Flores"   "Acosta"   "Billones"
fkr_full_name(3)
#> [1] "Jethro Delos Reyes" "Rosito Morales"     "Redford Gonzales"
fkr_sex(3)
#> [1] "Male" "Male" "Male"
fkr_civil_status(3)
#> [1] "Married" "Single"  "Single"
fkr_age(3)
#> [1] 21 13  0
fkr_birthday(3)
#> [1] "2018-10-27" "1979-09-11" "2024-11-27"

Contact details

fkr_email(3)
#> [1] "[email protected]"   "[email protected]"   
#> [3] "[email protected]"
fkr_mobile_number(3)
#> [1] "09946182267" "09190102688" "09750353292"
fkr_landline_number(3)
#> [1] "(083) 176 7841" "(049) 446 1306" "(046) 034 0035"

Addresses and places in the Philippines

fkr_region(3)
#> [1] "Region V (Bicol Region)"               
#> [2] "Region II (Cagayan Valley)"            
#> [3] "Cordillera Administrative Region (CAR)"
fkr_province(3)
#> [1] "Bukidnon"       "Northern Samar" "Kalinga"
fkr_city(3)
#> [1] "Sorsogon City"   "Dasmariñas City" "San Jose"
fkr_barangay(3)
#> [1] "Riverside" "Tuktukan"  "Poblacion"
fkr_street_address(3)
#> [1] "527 Lacson Extension"      "356 Mabini Street"        
#> [3] "832 Shaw Boulevard Avenue"

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              575 Bonifacio Road     Mabuhay   Muntinlupa Metro Manila
#> 2           590 Legarda Extension Kaligayahan      Romblon      Romblon
#> 3 305 Maharlika Highway Extension Kaligayahan Isabela City      Basilan
#>                                                    region  zip
#> 1                           National Capital Region (NCR) 1770
#> 2                                         MIMAROPA Region 5500
#> 3 Bangsamoro Autonomous Region In Muslim Mindanao (BARMM) 7300

Government ID-style numbers

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

fkr_sss_number(3)
#> [1] "94-7026415-4" "93-7556921-4" "96-5596463-7"
fkr_tin_number(3)
#> [1] "804-329-218-997" "078-932-739-338" "847-402-656-661"
fkr_philhealth_number(3)
#> [1] "97-379181632-5" "52-240914757-8" "66-515317471-6"
fkr_pagibig_number(3)
#> [1] "0346-6421-8290" "6889-1800-3081" "0348-9721-5067"
fkr_philsys_number(3)
#> [1] "6063-2872-8821-2173" "2161-3034-5127-5108" "2540-1574-9030-0558"

Businesses and jobs

fkr_company(3)
#> [1] "Magpantay & Garcia Development Corporation Ltd."
#> [2] "Canete Realty Corp."                            
#> [3] "Delos Santos & Garcia Marketing Co."
fkr_job_title(3)
#> [1] "HR Officer"        "Branch Manager"    "Account Executive"
fkr_industry(3)
#> [1] "Business Consulting" "Construction"        "Fisheries"
fkr_product(3)
#> [1] "Longganisa Pack"   "Bottled Soy Sauce" "Longganisa Pack"
fkr_price(3)
#> [1] "PHP 2,452.12" "PHP 18.09"    "PHP 1,563.75"

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] 15.91 33.82  8.92 57.49 32.63
fkr_int(5, min = 18, max = 65)          # whole numbers, e.g. an age range
#> [1] 59 21 60 20 41
fkr_boolean(5)                          # TRUE / FALSE, e.g. "has a Facebook account?"
#> [1]  TRUE FALSE  TRUE FALSE FALSE
fkr_uuid(3)                             # a unique ID for each record
#> [1] "0496e582-f10c-4843-b706-4887efc008c2"
#> [2] "c15696fc-6e3d-40fb-9e7d-551254081476"
#> [3] "80b17466-37a6-47d8-97a7-53ec3f41b5f8"

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"      "Email, Phone, SMS"
#> [4] "Email, Phone"      "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   Female Female Male  
#> 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 Male 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      Vilma Fernandez Female  16    2010-06-20   09296556463
#> 2    Alfonso   Miranda Female  23    2003-02-12   08960252724
#> 3      Jewel     Reyes   Male  26    2000-03-25   09960423066
#> 4    Melania Dela Cruz Female  32    1994-02-21   09540130113
#> 5      Carol Dela Cruz Female   3    2023-06-10   09794953943

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 Fabian Gabriel       543 Lacson Avenue       Bagumbayan  Iligan City
#> 2     Tala Basco         936 Mabini Road         Masagana     Caloocan
#> 3 Caroline Plaza 813 Aguinaldo Extension        Bayanihan  Maasin City
#>   address_province                address_region address_zip
#> 1  Lanao del Norte  Region X (Northern Mindanao)        9200
#> 2     Metro Manila National Capital Region (NCR)        1400
#> 3   Southern Leyte Region VIII (Eastern Visayas)        6600

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 Mandaue City
#> 2    Cebu City
#> 3    Cebu City
#> 4    Cebu 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   0 Minor
#> 2   4 Minor
#> 3  36 Adult
#> 4   0 Minor
#> 5   9 Minor
#> 6  38 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   8    2018-05-18
#> 2  26    2000-07-05
#> 3   5    2021-07-21
#> 4   0    2026-01-22
#> 5   0    2026-08-09

(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

  • Every function has its own help page. In R, type a question mark followed by the function’s name, e.g. ?fkr_address, to see exactly what settings it accepts.
  • The package’s README has a shorter, at-a-glance summary of everything covered here.