charlatan makes fake data, inspired from and borrowing some code from Python’s faker

Why would you want to make fake data? Here’s some possible use cases to give you a sense for what you can do with this package:

  • Students in a classroom setting learning any task that needs a dataset.
  • People doing simulations/modeling that need some fake data
  • Generate fake dataset of users for a database before actual users exist
  • Complete missing spots in a dataset
  • Generate fake data to replace sensitive real data with before public release
  • Create a random set of colors for visualization
  • Generate random coordinates for a map
  • Get a set of randomly generated DOIs (Digial Object Identifiers) to assign to fake scholarly artifacts
  • Generate fake taxonomic names for a biological dataset
  • Get a set of fake sequences to use to test code/software that uses sequence data

Contributing

See the Contributing to charlatan vignette

Package API

  • Low level interfaces: All of these are R6 objects that a user can initialize and then call methods on. These contain all the logic that the below interfaces use.
  • High level interfaces: There are high level functions prefixed with 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 above

Install

Stable version from CRAN

install.packages("charlatan")

Development version from Github

devtools::install_github("ropensci/charlatan")

high level function

… for all fake data operations

x <- fraudster()
x$job()
#> [1] "Psychologist, occupational"
x$name()
#> [1] "Chandler Treutel"
x$job()
#> [1] "Production assistant, radio"
x$color_name()
#> [1] "LightSalmon"

locale support

Adding more locales through time, e.g.,

Locale support for job data

ch_job(locale = "en_US", n = 3)
#> [1] "Insurance underwriter"               "Oncologist"                         
#> [3] "Chartered public finance accountant"
ch_job(locale = "fr_FR", n = 3)
#> [1] "Maréchal"               "Ingénieur process aval" "Greffier"
ch_job(locale = "hr_HR", n = 3)
#> [1] "Tesar"    "Kormilar" "Kuhar"
ch_job(locale = "uk_UA", n = 3)
#> [1] "Медик"    "Няня"     "Машиніст"
ch_job(locale = "zh_TW", n = 3)
#> [1] "大樓管理員"     "生產設備工程師" "珠心算老師"

For colors:

ch_color_name(locale = "en_US", n = 3)
#> [1] "LightCyan" "SeaShell"  "CadetBlue"
ch_color_name(locale = "uk_UA", n = 3)
#> [1] "Яскраво-рожевий"       "Лососевий"             "Блідий рожево-ліловий"

More coming soon …

generate a dataset

ch_generate()
#> # A tibble: 10 × 3
#>    name                  job                            phone_number      
#>    <chr>                 <chr>                          <chr>             
#>  1 Tyrus Leuschke        Chief Operating Officer        04160319532       
#>  2 Ms. Willie Heller     Water quality scientist        +09(8)6325992622  
#>  3 Elmina McGlynn        Risk manager                   (216)016-3177     
#>  4 Jerome Gerlach        Surveyor, building control     00045983492       
#>  5 Miss Mara Trantow PhD Community arts worker          415-104-7095      
#>  6 Dr. Roger Stark DDS   Media planner                  327-289-1101x3809 
#>  7 Johnathon Kertzmann   Equality and diversity officer 862-474-9220      
#>  8 Stephenie Hand        Clinical psychologist          588.214.5339      
#>  9 Mr. Ned Lemke PhD     Barista                        981-457-4470x776  
#> 10 Armani Terry          Dancer                         1-113-672-4833x909
ch_generate('job', 'phone_number', n = 30)
#> # A tibble: 30 × 2
#>    job                                               phone_number       
#>    <chr>                                             <chr>              
#>  1 Nurse, adult                                      (269)813-4414x35783
#>  2 Music tutor                                       450-250-7117       
#>  3 Financial planner                                 01230640264        
#>  4 Advertising art director                          00918692254        
#>  5 Higher education careers adviser                  025-380-7029       
#>  6 Embryologist, clinical                            363-981-9360x85296 
#>  7 Historic buildings inspector/conservation officer 725.678.2516       
#>  8 Operational investment banker                     1-740-398-2950x525 
#>  9 Engineer, structural                              08576421858        
#> 10 Designer, multimedia                              504.127.6260x06562 
#> # … with 20 more rows

Data types

person name

ch_name()
#> [1] "Dr. Sherrill Muller II"
ch_name(10)
#>  [1] "May Stark-Haley"          "Seldon Davis"            
#>  [3] "Alexus King"              "Kyson Lockman"           
#>  [5] "Mrs. Jasmyn Hauck PhD"    "Williard Welch"          
#>  [7] "Xiomara Franecki-D'Amore" "Gracia Prohaska DVM"     
#>  [9] "Kerry Skiles"             "Shanice Spinka"

phone number

ch_phone_number()
#> [1] "(792)092-7879x30916"
ch_phone_number(10)
#>  [1] "+62(3)7972448032"    "(494)799-3942x43907" "503-420-9890"       
#>  [4] "860-925-7659"        "1-303-352-0970"      "353-562-1719x460"   
#>  [7] "+27(3)2144317798"    "756-307-4886x288"    "(902)683-6690"      
#> [10] "790-491-0227x7565"

job

ch_job()
#> [1] "Recycling officer"
ch_job(10)
#>  [1] "Estate manager/land agent"     "Textile designer"             
#>  [3] "Podiatrist"                    "Engineer, civil (contracting)"
#>  [5] "Film/video editor"             "Clinical molecular geneticist"
#>  [7] "Soil scientist"                "Librarian, academic"          
#>  [9] "Psychologist, educational"     "Chief Operating Officer"

credit cards

ch_credit_card_provider()
#> [1] "Maestro"
ch_credit_card_provider(n = 4)
#> [1] "VISA 13 digit"    "Maestro"          "Voyager"          "American Express"
ch_credit_card_number()
#> [1] "4050064010825"
ch_credit_card_number(n = 10)
#>  [1] "6011623173331791501" "4704363407250829"    "869995477347918787" 
#>  [4] "4518437864455430"    "869963291405301754"  "52726276478525198"  
#>  [7] "4957354281624621"    "675996862667340"     "639093438767357"    
#> [10] "3528505004802480626"
ch_credit_card_security_code()
#> [1] "260"
ch_credit_card_security_code(10)
#>  [1] "449" "412" "424" "301" "987" "040" "294" "171" "647" "775"

Missing data

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.

testVector <- MissingDataProvider$new()

character strings

testVector$make_missing(x = ch_generate()$name) 
#>  [1] "Zackery Rowe-Grimes"         "Cara Beier PhD"             
#>  [3] NA                            "Hasel Jacobs"               
#>  [5] "Darla Hartmann"              NA                           
#>  [7] "Damarcus Klein"              NA                           
#>  [9] "Green Lueilwitz-Stiedemann"  "Adriana Wuckert-Greenfelder"

numeric data

testVector$make_missing(x = ch_integer(10)) 
#>  [1] 674 761 255  NA 799 517 164 795 223  43

logicals

set.seed(123)
testVector$make_missing(x = sample(c(TRUE, FALSE), 10, replace = TRUE)) 
#>  [1]  TRUE    NA    NA FALSE  TRUE    NA FALSE FALSE    NA  TRUE

Messy data

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 d.d.s."
#>  [3] "Jefferey Lesch"            "Inga Dach"                
#>  [5] "Keyshawn Schaefer"         "Ferdinand Bergstrom"      
#>  [7] "Justen Simonis"            "Ms. Doloris Stroman md"   
#>  [9] "Mrs Ermine Heidenreich"    "Marion Corwin"            
#> [11] "Jalen Grimes"              "Mr. Sullivan Hammes IV"   
#> [13] "Adrien Vandervort-Dickens" "Dr Sharif Kunde"          
#> [15] "Marlena Reichert d.d.s."   "Mr. Brandan Oberbrunner"  
#> [17] "Lloyd Adams Sr"            "Keesha Schowalter"        
#> [19] "Randy Ziemann"             "Gina Sanford"             
#> [21] "Cornell Funk"              "Yadiel Collier"           
#> [23] "Kamryn Johnson"            "Tyesha Schmeler"          
#> [25] "Ernie Hegmann-Graham"      "Zackery Runolfsdottir"    
#> [27] "Cleveland Predovic"        "Melvyn Hickle"            
#> [29] "Larry Nienow I"            "Nicola Langosh Ph.D."     
#> [31] "Ebenezer Fadel V"          "Andrae Hand-Eichmann"     
#> [33] "Shamar Harvey"             "Miss Lynn Altenwerth"     
#> [35] "Willene McLaughlin-Mohr"   "Kyree Kutch"              
#> [37] "Ms Delpha Grant"           "Ms. Icie Crooks"          
#> [39] "Loney Jenkins-Lindgren"    "Shania Donnelly DVM"      
#> [41] "Dr Patric Veum"            "Amirah Rippin DVM"        
#> [43] "Randle Hilpert"            "Soren Dare"               
#> [45] "Roderic Walter"            "Farah Daugherty DDS"      
#> [47] "Ryland Ledner"             "Girtha Harvey DVM"        
#> [49] "Tyrique 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.