charlatan
makes
realistic looking fake data, inspired from and borrowing some code from
Python’s faker
Why would you want to make fake data that looks real? Here’s some possible use cases to give you a sense for what you can do with this package:
See the Creating realistic data vignette for a few realistic examples.
See the Contributing to charlatan vignette.
R6
objects that
a user can initialize and then call methods on. These contain all the
logic that the below interfaces use.ch_*()
that wrap low level interfaces, and are meant to be
easier to use and provide an easy way to make many instances of a
thing.ch_generate()
- generate a data.frame with fake data,
choosing which columns to include from the data types provided in
charlatan
fraudster()
- single interface to all fake data
methods, - returns vectors/lists of data - this function wraps the
ch_*()
functions described aboveStable version from CRAN
Development version from Github
… for all fake data operations
Here we create 3 jobs, for different locales:
ch_job(locale = "en_US", n = 3)
#> [1] "Public librarian" "Editor, magazine features"
#> [3] "Herpetologist"
ch_job(locale = "fr_FR", n = 3)
#> [1] "Hydrologue" "Géologue minier" "Pédiatre"
ch_job(locale = "hr_HR", n = 3)
#> [1] "Konzervator tehničar"
#> [2] "Pediker"
#> [3] "Stručni suradnik ovlaštenog inženjera geodezije"
ch_job(locale = "uk_UA", n = 3)
#> [1] "Реставратор" "Підприємець" "Каскадер"
ch_job(locale = "zh_TW", n = 3)
#> [1] "特殊工程師" "安親班老師" "類比IC設計工程師"
For colors:
ch_generate()
#> # A tibble: 10 × 3
#> name job phone_number
#> <chr> <chr> <chr>
#> 1 Mr. Sammie O'Reilly Television production assistant 326-318-3851x116
#> 2 Ms. Charlie Schoen Therapist, speech and language 1-950-659-3121x93103
#> 3 Ms. Bonita Kessler MD Adult nurse 1-480-353-4414x99590
#> 4 Miss Marget Sawayn DDS Furniture conservator/restorer (525)751-5753x10373
#> 5 North Schumm Animal nutritionist 1-099-828-5738
#> 6 Dr. Octavia Harber MD Magazine features editor 908.295.0724x3725
#> 7 Cressie Vandervort Theatre director 1-469-687-8198x12080
#> 8 Natalee Crist Cabin crew +83(1)9044595393
#> 9 Vonnie Bergstrom MD Higher education careers adviser (439)969-0309x172
#> 10 Cadence Feeney Therapist, occupational 1-578-166-5130
ch_generate("job", "phone_number", n = 30)
#> # A tibble: 30 × 2
#> job phone_number
#> <chr> <chr>
#> 1 English as a foreign language teacher 868-774-7172x6811
#> 2 Engineer, agricultural 1-234-699-5943x855
#> 3 Psychotherapist, child (274)133-4184
#> 4 Medical physicist 770-832-0187
#> 5 Teacher, music (603)619-8601x405
#> 6 Scientific laboratory technician (024)436-5539x40762
#> 7 Pilot, airline 1-626-903-9861x110
#> 8 Commercial horticulturist 05030117281
#> 9 Financial adviser (078)498-3591
#> 10 Designer, textile 793.889.4295x19267
#> # ℹ 20 more rows
We can create locale specific versions of:
Examples:
Some data types are not localized (arguably the files and user_agents, are mostly universal too).
ch_credit_card_provider()
#> [1] "American Express"
ch_credit_card_provider(n = 4)
#> [1] "JCB 15 digit" "VISA 16 digit" "JCB 15 digit" "Mastercard"
ch_credit_card_number()
#> [1] "210090811545037005"
ch_credit_card_number(n = 10)
#> [1] "210021413356967638" "3438031621338988" "55817578986016614"
#> [4] "4245188512154244" "3028153078999751" "3053222722836035"
#> [7] "210007411722342005" "53404431760496801" "3732305459543133"
#> [10] "3713741823905249"
charlatan
makes it very easy to generate fake data with
missing entries. First, you need to run
MissingDataProvider()
and then make an appropriate
make_missing()
call specifying the data type to be
generated. This method picks a random number (N
) of slots
in the input make_missing
vector and then picks
N
random positions that will be replaced with NA matching
the input class.
Real data is messy, right? charlatan
makes it easy to
create messy data. This is still in the early stages so is not available
across most data types and languages, but we’re working on it.
For example, create messy names:
ch_name(50, messy = TRUE)
#> [1] "Destiney Dicki" "Mrs. Freddie Pouros DDS"
#> [3] "Ms. Jada Lesch" "Inga Dach"
#> [5] "Keyshawn Schaefer" "Ferdinand Bergstrom"
#> [7] "Justen Simonis" "Ms. Doloris Stroman DVM"
#> [9] "Mrs. Ermine Heidenreich" "Marion Corwin"
#> [11] "Jalen Grimes" "Mr. Sullivan Hammes IV"
#> [13] "Adrien Vandervort-Dickens" "Dr. Sharif Kunde"
#> [15] "Marlena Reichert PhD" "Mr. Brandan Oberbrunner"
#> [17] "Lloyd Adams III" "Randy Ziemann"
#> [19] "Gina Sanford" "Cornell Funk"
#> [21] "Yadiel Collier" "Kamryn Johnson"
#> [23] "Tyesha Schmeler" "Ernie Hegmann-Graham"
#> [25] "Zackery Runolfsdottir" "Cleveland Predovic"
#> [27] "Melvyn Hickle" "Larry Nienow IV"
#> [29] "Vilma Rutherford" "Wiliam Ziemann-Fadel"
#> [31] "Mrs. Kathy Halvorson" "Mirtie Harvey-Shanahan"
#> [33] "Eliezer Pfeffer" "Dr. Shep Buckridge"
#> [35] "Kyree Kutch" "Ms. Delpha Grant"
#> [37] "Ms. Icie Crooks" "Loney Jenkins-Lindgren"
#> [39] "Shania Donnelly DVM" "Dr. Patric Veum"
#> [41] "Amirah Rippin DVM" "Randle Hilpert"
#> [43] "Soren Dare" "Roderic Walter"
#> [45] "Farah Daugherty MD" "Marva Crooks"
#> [47] "Ryland Ledner" "Girtha Harvey DDS"
#> [49] "Staci Spencer" "Mr. Olan Bernhard"
Right now only suffixes and prefixes for names in en_US
locale are supported. Notice above some variation in prefixes and
suffixes.