<p><strong>charlatan</strong> makes fake data.</p>
<p>Excited to annonunce a new package called <code>charlatan</code>. While perusing
packages from other programming languages, I saw a neat Python library
called <code>faker</code>.</p>
<p><code>charlatan</code> is inspired from and ports many things from Python's
<a href="https://github.com/joke2k/faker">https://github.com/joke2k/faker</a> library. In turn, <code>faker</code> was inspired from
<a href="https://github.com/fzaninotto/Faker">PHP's faker</a>,
<a href="http://search.cpan.org/~jasonk/Data-Faker-0.07/">Perl's Faker</a>, and
<a href="https://rubygems.org/gems/faker">Ruby's faker</a>. It appears that the PHP
library was the original - nice work PHP.</p>
<h3>Use cases</h3>
<p>What could you do with this package? Here's some use cases:</p>
<ul>
<li>Students in a classroom setting learning any task that needs a dataset.</li>
<li>People doing simulations/modeling that need some fake data</li>
<li>Generate fake dataset of users for a database before actual users exist</li>
<li>Complete missing spots in a dataset</li>
<li>Generate fake data to replace sensitive real data with before public release</li>
<li>Create a random set of colors for visualization</li>
<li>Generate random coordinates for a map</li>
<li>Get a set of randomly generated DOIs (Digial Object Identifiers) to
assign to fake scholarly artifacts</li>
<li>Generate fake taxonomic names for a biological dataset</li>
<li>Get a set of fake sequences to use to test code/software that uses
sequence data</li>
</ul>
<h3>Features</h3>
<ul>
<li>Language support: A huge selling point of <code>charlatan</code> is language support.
Of course for some data types (numbers), languages don't come into play, but
for many they do. That means you can create fake datasets specific to a
language, or a dataset with a mix of languages, etc. For the variables
in this package, we have not yet ported over all languages for those
variables that Python's <code>faker</code> has.</li>
<li>Lite weight: We've tried to make this package as lite as possible so
that it's just generally easy to install, but also can be used in
other packages or workflows while bringing along as little baggage
as possible.</li>
<li>Reviewed: it's been reviewed! See reviews by <a href="http://ropensci.org/reviewba">Brooke Anderson</a> and
<a href="http://ropensci.org/feed.xml">Tristan Mahr</a>, and handling editor <a href="https://github.com/noamross">Noam Ross</a>
</li>
<li>R specific features such as methods to create data.frame's (so the
user doesn’t have to do the extra step of putting vectors together)</li>
</ul>
<h3>Status</h3>
<p>We have not ported every variable, or every language yet in those variables.
We have added some variables to <code>charlatan</code> that are not in <code>faker</code> (e.g.,
taxonomy, gene sequences). Check out the <a href="https://github.com/ropensci/charlatan/issues">issues</a>
to follow progress.</p>
<h3>Package API</h3>
<ul>
<li>
<code>ch_generate</code>: generate a data.frame with fake data</li>
<li>
<code>fraudster</code>: single interface to all fake data methods</li>
<li>High level interfaces: There are high level functions prefixed with
<code>ch_</code> that wrap low level interfaces, and are meant to be easier
to use and provide easy way to make many instances of a thing.</li>
<li>Low level interfaces: All of these are R6 objects that a user can
initialize and then call methods on the them.</li>
</ul>
<h3>Other R work in this space:</h3>
<ul>
<li><a href="https://github.com/paulhendricks/generator">generator</a></li>
<li><a href="https://cran.rstudio.com/web/packages/fakeR/">fakeR</a></li>
<li><a href="https://github.com/karthik/randNames">randNames</a></li>
</ul>
<h3>Vignette</h3>
<p>Check out the <a href="https://cran.rstudio.com/web/packages/charlatan/vignettes/charlatan_vignette.html">package vignette</a> to get started.</p>
<h2>setup</h2>
<p>Install <code>charlatan</code></p>
<div><pre><code><span></span>install.packages<span>(</span><span>&quot;charlatan&quot;</span><span>)</span>
</code></pre></div>
<p>Or get the development version:</p>
<div><pre><code><span></span>devtools<span>::</span>install_github<span>(</span><span>&quot;ropensci/charlatan&quot;</span><span>)</span>
</code></pre></div>
<div><pre><code><span></span><span>library</span><span>(</span>charlatan<span>)</span>
</code></pre></div>
<h2>Examples</h2>
<h3>high level interface</h3>
<p><code>fraudster</code> is an interface for all fake data variables (and locales):</p>
<div><pre><code><span></span>x <span>&lt;-</span> fraudster<span>()</span>
x<span>$</span>job<span>()</span>
<span>#> [1] &quot;Textile designer&quot;</span>
x<span>$</span>name<span>()</span>
<span>#> [1] &quot;Cris Johnston-Tremblay&quot;</span>
x<span>$</span>job<span>()</span>
<span>#> [1] &quot;Database administrator&quot;</span>
x<span>$</span>color_name<span>()</span>
<span>#> [1] &quot;SaddleBrown&quot;</span>
</code></pre></div>
<p>If you want to set locale, do so like <code>fraudster(locale = &quot;{locale}&quot;)</code></p>
<h3>locale support</h3>
<p>The locales that are supported vary by data variable. We're adding more
locales through time, so do check in from time to time - or even better,
send a pull request adding support for the locale you want for the
variable(s) you want.</p>
<p>As an example, you can set locale for job data to any number of supported
locales.</p>
<p>For jobs:</p>
<div><pre><code><span></span>ch_job<span>(</span>locale <span>=</span> <span>&quot;en_US&quot;</span><span>,</span> n <span>=</span> <span>3</span><span>)</span>
<span>#> [1] &quot;Charity officer&quot; &quot;Financial adviser&quot; &quot;Buyer, industrial&quot;</span>
ch_job<span>(</span>locale <span>=</span> <span>&quot;fr_FR&quot;</span><span>,</span> n <span>=</span> <span>3</span><span>)</span>
<span>#> [1] &quot;Illustrateur&quot; &quot;Guichetier&quot;</span>
<span>#> [3] &quot;Responsable d'ordonnancement&quot;</span>
ch_job<span>(</span>locale <span>=</span> <span>&quot;hr_HR&quot;</span><span>,</span> n <span>=</span> <span>3</span><span>)</span>
<span>#> [1] &quot;Pomoćnik strojovođe&quot;</span>
<span>#> [2] &quot;Pećar&quot;</span>
<span>#> [3] &quot;Konzervator – restaurator savjetnik&quot;</span>
ch_job<span>(</span>locale <span>=</span> <span>&quot;uk_UA&quot;</span><span>,</span> n <span>=</span> <span>3</span><span>)</span>
<span>#> [1] &quot;Фрілансер&quot; &quot;Астрофізик&quot; &quot;Доцент&quot;</span>
ch_job<span>(</span>locale <span>=</span> <span>&quot;zh_TW&quot;</span><span>,</span> n <span>=</span> <span>3</span><span>)</span>
<span>#> [1] &quot;包裝設計&quot; &quot;空調冷凍技術人員&quot; &quot;鍋爐操作技術人員&quot;</span>
</code></pre></div>
<p>For colors:</p>
<div><pre><code><span></span>ch_color_name<span>(</span>locale <span>=</span> <span>&quot;en_US&quot;</span><span>,</span> n <span>=</span> <span>3</span><span>)</span>
<span>#> [1] &quot;DarkMagenta&quot; &quot;Navy&quot; &quot;LightGray&quot;</span>
ch_color_name<span>(</span>locale <span>=</span> <span>&quot;uk_UA&quot;</span><span>,</span> n <span>=</span> <span>3</span><span>)</span>
<span>#> [1] &quot;Синій ВПС&quot; &quot;Темно-зелений хакі&quot; &quot;Берлінська лазур&quot;</span>
</code></pre></div>
<p><code>charlatan</code> will tell you when a locale is not supported</p>
<div><pre><code><span></span>ch_job<span>(</span>locale <span>=</span> <span>&quot;cv_MN&quot;</span><span>)</span>
<span>#> Error: cv_MN not in set of available locales</span>
</code></pre></div>
<h3>generate a dataset</h3>
<p><code>ch_generate()</code> helps you create data.frame's with whatever variables
you want that <code>charlatan</code> supports. Then you're ready to use the
data.frame immediately in whatever your application is.</p>
<p>By default, you get back a certain set of variables. Right now, that is:
<code>name</code>, <code>job</code>, and <code>phone_number</code>.</p>
<div><pre><code><span></span>ch_generate<span>()</span>
<span>#> # A tibble: 10 x 3</span>
<span>#> name job</span>
<span>#> &lt;chr> &lt;chr></span>
<span>#> 1 Coy Davis Geneticist, molecular</span>
<span>#> 2 Artis Senger Press sub</span>
<span>#> 3 Tal Rogahn Town planner</span>
<span>#> 4 Nikolas Carter Barrister's clerk</span>
<span>#> 5 Sharlene Kemmer Insurance account manager</span>
<span>#> 6 Babyboy Volkman Quality manager</span>
<span>#> 7 Dr. Josephus Marquardt DVM Best boy</span>
<span>#> 8 Vernal Dare Engineer, site</span>
<span>#> 9 Emilia Hessel Administrator, arts</span>
<span>#> 10 Urijah Beatty Editor, commissioning</span>
<span>#> # ... with 1 more variables: phone_number &lt;chr></span>
</code></pre></div>
<p>You can select just the variables you want:</p>
<div><pre><code><span></span>ch_generate<span>(</span><span>'job'</span><span>,</span> <span>'phone_number'</span><span>,</span> n <span>=</span> <span>30</span><span>)</span>
<span>#> # A tibble: 30 x 2</span>
<span>#> job phone_number</span>
<span>#> &lt;chr> &lt;chr></span>
<span>#> 1 Call centre manager 1-670-715-3079x9104</span>
<span>#> 2 Nurse, learning disability 1-502-781-3386x33524</span>
<span>#> 3 Network engineer 1-692-089-3060</span>
<span>#> 4 Industrial buyer 1-517-855-8517</span>
<span>#> 5 Database administrator (999)474-9975x89650</span>
<span>#> 6 Operations geologist 06150655769</span>
<span>#> 7 Engineer, land 360-043-3630x592</span>
<span>#> 8 Pension scheme manager (374)429-6821</span>
<span>#> 9 Personnel officer 1-189-574-3348x338</span>
<span>#> 10 Editor, film/video 1-698-135-1664</span>
<span>#> # ... with 20 more rows</span>
</code></pre></div>
<h3>Data types</h3>
<p>A sampling of the data types available in <code>charlatan</code>:</p>
<p><strong>person name</strong></p>
<div><pre><code><span></span>ch_name<span>()</span>
<span>#> [1] &quot;Jefferey West-O'Connell&quot;</span>
</code></pre></div>
<div><pre><code><span></span>ch_name<span>(</span><span>10</span><span>)</span>
<span>#> [1] &quot;Dylon Hintz&quot; &quot;Dr. Billy Willms DDS&quot; &quot;Captain Bednar III&quot;</span>
<span>#> [4] &quot;Carli Torp&quot; &quot;Price Strosin III&quot; &quot;Grady Mayert&quot;</span>
<span>#> [7] &quot;Nat Herman-Kuvalis&quot; &quot;Noelle Funk&quot; &quot;Dr. Jaycie Herzog MD&quot;</span>
<span>#> [10] &quot;Ms. Andrea Zemlak&quot;</span>
</code></pre></div>
<p><strong>phone number</strong></p>
<div><pre><code><span></span>ch_phone_number<span>()</span>
<span>#> [1] &quot;643.993.1958&quot;</span>
</code></pre></div>
<div><pre><code><span></span>ch_phone_number<span>(</span><span>10</span><span>)</span>
<span>#> [1] &quot;+06(6)6080789632&quot; &quot;05108334280&quot; &quot;447-126-9775&quot;</span>
<span>#> [4] &quot;+96(7)2112213020&quot; &quot;495-425-1506&quot; &quot;1-210-372-3188x514&quot;</span>
<span>#> [7] &quot;(300)951-5115&quot; &quot;680.567.5321&quot; &quot;1-947-805-4758x8167&quot;</span>
<span>#> [10] &quot;888-998-5511x554&quot;</span>
</code></pre></div>
<p><strong>job</strong></p>
<div><pre><code><span></span>ch_job<span>()</span>
<span>#> [1] &quot;Scientist, water quality&quot;</span>
</code></pre></div>
<div><pre><code><span></span>ch_job<span>(</span><span>10</span><span>)</span>
<span>#> [1] &quot;Engineer, production&quot;</span>
<span>#> [2] &quot;Architect&quot;</span>
<span>#> [3] &quot;Exhibitions officer, museum/gallery&quot;</span>
<span>#> [4] &quot;Patent attorney&quot;</span>
<span>#> [5] &quot;Surveyor, minerals&quot;</span>
<span>#> [6] &quot;Electronics engineer&quot;</span>
<span>#> [7] &quot;Secondary school teacher&quot;</span>
<span>#> [8] &quot;Intelligence analyst&quot;</span>
<span>#> [9] &quot;Nutritional therapist&quot;</span>
<span>#> [10] &quot;Information officer&quot;</span>
</code></pre></div>
<h3>Messy data</h3>
<p>Real data is messy! <code>charlatan</code> 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.</p>
<p>For example, create messy names:</p>
<div><pre><code><span></span>ch_name<span>(</span><span>50</span><span>,</span> messy <span>=</span> <span>TRUE</span><span>)</span>
<span>#> [1] &quot;Mr. Vernell Hoppe Jr.&quot; &quot;Annika Considine d.d.s.&quot;</span>
<span>#> [3] &quot;Dr. Jose Kunde DDS&quot; &quot;Karol Leuschke-Runte&quot;</span>
<span>#> [5] &quot;Kayleen Kutch-Hintz&quot; &quot;Jahir Green&quot;</span>
<span>#> [7] &quot;Stuart Emmerich&quot; &quot;Hillard Schaden&quot;</span>
<span>#> [9] &quot;Mr. Caden Braun&quot; &quot;Willie Ebert&quot;</span>
<span>#> [11] &quot;Meg Abbott PhD&quot; &quot;Dr Rahn Huel&quot;</span>
<span>#> [13] &quot;Kristina Crooks d.d.s.&quot; &quot;Lizbeth Hansen&quot;</span>
<span>#> [15] &quot;Mrs. Peyton Kuhn&quot; &quot;Hayley Bernier&quot;</span>
<span>#> [17] &quot;Dr. Lavon Schimmel d.d.s.&quot; &quot;Iridian Murray&quot;</span>
<span>#> [19] &quot;Cary Romaguera&quot; &quot;Tristan Windler&quot;</span>
<span>#> [21] &quot;Marlana Schroeder md&quot; &quot;Mr. Treyton Nitzsche&quot;</span>
<span>#> [23] &quot;Hilmer Nitzsche-Glover&quot; &quot;Marius Dietrich md&quot;</span>
<span>#> [25] &quot;Len Mertz&quot; &quot;Mrs Adyson Wunsch DVM&quot;</span>
<span>#> [27] &quot;Dr. Clytie Feest DDS&quot; &quot;Mr. Wong Lebsack I&quot;</span>
<span>#> [29] &quot;Arland Kessler&quot; &quot;Mrs Billy O'Connell m.d.&quot;</span>
<span>#> [31] &quot;Stephen Gerlach&quot; &quot;Jolette Lueilwitz&quot;</span>
<span>#> [33] &quot;Mrs Torie Green d.d.s.&quot; &quot;Mona Denesik&quot;</span>
<span>#> [35] &quot;Mitchell Auer&quot; &quot;Miss. Fae Price m.d.&quot;</span>
<span>#> [37] &quot;Todd Lehner&quot; &quot;Elva Lesch&quot;</span>
<span>#> [39] &quot;Miss. Gustie Rempel DVM&quot; &quot;Lexie Parisian-Stark&quot;</span>
<span>#> [41] &quot;Beaulah Cremin-Rice&quot; &quot;Parrish Schinner&quot;</span>
<span>#> [43] &quot;Latrell Beier&quot; &quot;Garry Wolff Sr&quot;</span>
<span>#> [45] &quot;Bernhard Vandervort&quot; &quot;Stevie Johnston&quot;</span>
<span>#> [47] &quot;Dawson Gaylord&quot; &quot;Ivie Labadie&quot;</span>
<span>#> [49] &quot;Ronal Parker&quot; &quot;Mr Willy O'Conner Sr.&quot;</span>
</code></pre></div>
<p>Right now only suffixes and prefixes for names in <code>en_US</code> locale
are supported. Notice above some variation in prefixes and suffixes.</p>
<h2>TO DO</h2>
<p>We have lots ot do still. Some of those things include:</p>
<ul>
<li>Locales: For existing data variables in the package, we need to fill in
locales for which Python's <code>faker</code> has the data, but we need to port it over
still.</li>
<li>Data variables: there's more we can port over from Python's <code>faker</code>.
In addition, we may find inspiration from faker libraries in other
programming languages.</li>
<li>Messy data: we want to make messy data support more available throughout
the package. Watch <a href="https://github.com/ropensci/charlatan/issues/41">issue #41</a>.</li>
<li>If you have ideas for potential data variables, <a href="https://github.com/ropensci/charlatan/issues/11">issue #11</a> is a good place for those.
Or open a new issue, either way.</li>
<li>One reviewer brought up whether data should be within bounds of reality (
see <a href="https://github.com/ropensci/charlatan/issues/40">issue #40</a>). The first
question for me is should we do this - if the answer is yes or at least sometimes,
then we can explore how. It's not yet clear if it's the right thing to do.</li>
</ul>