<p><strong>charlatan</strong> makes fake data.</p>
<p>Excited to annonunce a new package called <code>charlatan</code>. While perusing<br>
packages from other programming languages, I saw a neat Python library<br>
called <code>faker</code>.</p>
<p><code>charlatan</code> is inspired from and ports many things from Python's<br>
<a rel="nofollow" href="https://github.com/joke2k/faker" target="_blank">https://github.com/joke2k/faker</a> library. In turn, <code>faker</code> was inspired from<br>
<a rel="nofollow" href="https://github.com/fzaninotto/Faker" target="_blank">PHP's faker</a>,<br>
<a rel="nofollow" href="http://search.cpan.org/~jasonk/Data-Faker-0.07/" target="_blank">Perl's Faker</a>, and<br>
<a rel="nofollow" href="https://rubygems.org/gems/faker" target="_blank">Ruby's faker</a>. It appears that the PHP<br>
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<br>
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<br>
sequence data</li>
</ul>
<h3>Features</h3>
<ul>
<li>Language support: A huge selling point of <code>charlatan</code> is language support.<br>
Of course for some data types (numbers), languages don't come into play, but<br>
for many they do. That means you can create fake datasets specific to a<br>
language, or a dataset with a mix of languages, etc. For the variables<br>
in this package, we have not yet ported over all languages for those<br>
variables that Python's <code>faker</code> has.</li>
<li>Lite weight: We've tried to make this package as lite as possible so<br>
that it's just generally easy to install, but also can be used in<br>
other packages or workflows while bringing along as little baggage<br>
as possible.</li>
<li>Reviewed: it's been reviewed! See reviews by <a rel="nofollow" href="http://ropensci.org/blog/technotes/2017/06/22/reviewba" target="_blank">Brooke Anderson</a> and<br>
<a rel="nofollow" href="http://ropensci.org/blog/technotes/2017/06/22/charlatan" target="_blank">Tristan Mahr</a>, and handling editor <a rel="nofollow" href="https://github.com/noamross" target="_blank">Noam Ross</a></li>
<li>R specific features such as methods to create data.frame's (so the<br>
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.<br>
We have added some variables to <code>charlatan</code> that are not in <code>faker</code> (e.g.,<br>
taxonomy, gene sequences). Check out the <a rel="nofollow" href="https://github.com/ropensci/charlatan/issues" target="_blank">issues</a><br>
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<br>
<code>ch_</code> that wrap low level interfaces, and are meant to be easier<br>
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<br>
initialize and then call methods on the them.</li>
</ul>
<h3>Other R work in this space:</h3>
<ul>
<li><a rel="nofollow" href="https://github.com/paulhendricks/generator" target="_blank">generator</a></li>
<li><a rel="nofollow" href="https://cran.rstudio.com/web/packages/fakeR/" target="_blank">fakeR</a></li>
<li><a rel="nofollow" href="https://github.com/karthik/randNames" target="_blank">randNames</a></li>
</ul>
<h3>Vignette</h3>
<p>Check out the <a rel="nofollow" href="https://cran.rstudio.com/web/packages/charlatan/vignettes/charlatan_vignette.html" target="_blank">package vignette</a> to get started.</p>
<h2>setup</h2>
<p>Install <code>charlatan</code></p>
<div>
<pre><code data-lang="r"><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 data-lang="r"><span></span>devtools<span>::</span>install_github<span>(</span><span>&quot;ropensci/charlatan&quot;</span><span>)</span>
</code></pre>
</div>
<div>
<pre><code data-lang="r"><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 data-lang="r"><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<br>
locales through time, so do check in from time to time – or even better,<br>
send a pull request adding support for the locale you want for the<br>
variable(s) you want.</p>
<p>As an example, you can set locale for job data to any number of supported<br>
locales.</p>
<p>For jobs:</p>
<div>
<pre><code data-lang="r"><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 data-lang="r"><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 data-lang="r"><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<br>
you want that <code>charlatan</code> supports. Then you're ready to use the<br>
data.frame immediately in whatever your application is.</p>
<p>By default, you get back a certain set of variables. Right now, that is:<br>
<code>name</code>, <code>job</code>, and <code>phone_number</code>.</p>
<div>
<pre><code data-lang="r"><span></span>ch_generate<span>()</span>
<span>#> # A tibble: 10 x 3</span>
<span>#> name job</span>
<span>#> </span></code></pre></div>