<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/so-you-want-to-play-a-prank-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://theautomatic.net/2018/12/18/so-you-want-to-play-a-prank-in-r/"> R – Open Source Automation</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img alt="matrix" src="https://i1.wp.com/theautomatic.net/wp-content/uploads/2018/12/matrix-434035_640.jpg?w=640" data-recalc-dims="1"></p>
<p>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/using-ggplot2-for-functional-time-series/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://robjhyndman.com/hyndsight/ftsviz/"> R on Rob J Hyndman</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>This week I’ve been attending the <a rel="nofollow" href="https://www.matrix-inst.org.au/events/functional-data-analysis-and-beyond/" target="_blank">Functional Data and Beyond workshop</a> at the Matrix centre in Creswick.</p>
<p>I spoke yesterday about using <code>ggplot2</code> for functional data graphics, rather than the custom-built plotting functionality available in the many functional data packages, including my own <a rel="nofollow" href="https://cran.r-project.org/package=rainbow" target="_blank">rainbow package</a> written with Hanlin Shang.</p>
<p>It is a much more powerful and flexible way to work, so I thought it would be useful to share some examples.</p>
<div>
<h2>French mortality data</h2>
<p>We will use the French mortality data from the <code>demography</code> package, but we need to convert it into a tibble to begin.</p>
<pre><code>library(tidyverse)
library(demography)

# Combine age groups above 100
frmort &lt;- set.upperage(fr.mort, 100)
# Create tibble
frmort &lt;- tibble(
      year = rep(frmort$year, rep(length(frmort$age), length(frmort$year))),
      age = rep(frmort$age, length(frmort$year)),
      female = c(frmort$rate$female),
      male = c(frmort$rate$male),
    ) %>%
  gather(male, female, key = &quot;sex&quot;, value = &quot;mortrate&quot;)
frmort</code></pre>
<pre><code>## # A tibble: 38,582 x 4
##     year   age sex   mortrate
##    </code></pre></div>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/10-r-functions-for-linux-commands-and-vice-versa/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://theautomatic.net/2018/12/10/10-r-functions-for-linux-commands-and-vice-versa/"> R – Open Source Automation</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img alt="linux vs. r commands" src="https://i1.wp.com/theautomatic.net/wp-content/uploads/2018/12/linux-vs.-r-commands.jpg?w=640" data-recalc-dims="1"></p>
<p>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/a-tutorial-on-tidy-cross-validation-with-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.brodrigues.co/blog/2018-11-25-tidy_cv/"> Econometrics and Free Software</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p><a rel="nofollow" href="https://www.youtube.com/watch?v=7T6pgZdFLP0" target="_blank"><br>
</a></div>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/installing-rstudio-shiny-servers/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://datawookie.netlify.com/blog/2018/11/installing-rstudio--shiny-servers/"> R on datawookie</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I did a remote install of Ubuntu Server today. This was somewhat novel because it’s the first time that I have not had physical access to the machine I was installing on. The server install went very smoothly indeed.</p>
<p>The next tasks were to install RStudio Server and Shiny Server. The installation process for each of these is well documented on the RStudio web site:</p>
<ul>
<li><a rel="nofollow" href="https://www.rstudio.com/products/rstudio/download-server/" target="_blank">Installing RStudio Server</a> and</li>
<li><a rel="nofollow" href="https://www.rstudio.com/products/shiny/download-server/" target="_blank">Installing Shiny Server</a>.</li>
</ul>
<p>These are my notes. Essentially the same, with some small variations.</p>
<h2>RStudio Server</h2>
<ol>
<li>Install a recent version of R.</li>
<li>
<p>Download the distribution.</p>
<div>
<pre><code data-lang="bash">wget https://download2.rstudio.org/rstudio-server-1.1.463-amd64.deb</code></pre>
</div>
</li>
<li>
<p>Install the server.</p>
<div>
<pre><code data-lang="bash">sudo dpkg -i rstudio-server-1.1.463-amd64.deb</code></pre>
</div>
</li>
<li>
<p>Verify the installation.</p>
<div>
<pre><code data-lang="bash">sudo rstudio-server verify-installation</code></pre>
</div>
</li>
<li>
<p>RStudio Server runs on port 8787, so you should be able to access it in a browser at <code>http://</code></ol>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/how-to-run-r-from-the-task-scheduler/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://theautomatic.net/2018/10/31/how-to-run-r-from-the-task-scheduler/"> R – Open Source Automation</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img alt="run r from the task scheduler" src="https://i2.wp.com/theautomatic.net/wp-content/uploads/2018/08/run-r-from-task-scheduler.jpeg?w=640" data-recalc-dims="1"></p>
<p>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/data-analysis-with-python-course-how-to-read-wrangle-and-analyze-data/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://theautomatic.net/2018/10/31/data-analysis-with-python-course-how-to-read-wrangle-and-analyze-data/"> Open Source Automation</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img alt="python data analysis nyc course" src="https://i1.wp.com/theautomatic.net/wp-content/uploads/2018/10/python-nyc-event-data-analysis.jpg?w=640" data-recalc-dims="1"></p>
<p>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/subsetting-in-the-presence-of-nas/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://statisticaloddsandends.wordpress.com/2018/10/07/subsetting-in-the-presence-of-nas/"> R – Statistical Odds &amp; Ends</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>In R, we can subset a data frame <code>df</code> easily by putting the conditional in square brackets after <code>df</code>. For example, if I want all the rows in <code>df</code> which have value equal to 1 in the column <code>colA</code>, all I have to do is</p>
<pre>
df[df$colA == 1, ]
</pre>
<p>Recently, I realized that this approach can be problematic when there are NAs present in the data! For example, let <code>df</code> be the following data frame:</p>
<pre>
df &lt;- data.frame(colA = c(1, 2, 3, NA, NA),
                 colB = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, NA))
df

# co1A colB
# 1    1    a
# 2    2    b
# 3    3    c
# 4   NA    d
# 5   NA </pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/using-rs-set-seed-to-set-seeds-for-use-in-c-c-including-rcpp/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://rorynolan.rbind.io/2018/09/30/rcsetseed/"> R on roryverse</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>In native R, the user sets the seed for random number generation (RNG) with <code>set.seed()</code>. Random number generators exist in C and C++ too; these need their own seeds, which are not obviously settable by <code>set.seed()</code>. Good news! It can be done.</p>
<pre><code>pacman::p_load(inline, purrr)</code></pre>
<div>
<h1><code>rbernoulli</code></h1>
<p>Base R (or technically the <code>stats</code> package) provides no <code>rbernoulli()</code>. It’s a pretty gaping hole in the pantheon of <code>rbeta()</code>, <code>rbinom()</code>, <code>rcauchy</code>, <code>rchisq()</code>, <code>rexp()</code>, <code>rf()</code>, <code>rgamma()</code>, etc. Thankfully, Hadley Wickham noticed this and gave us <code>purrr::rbernoulli()</code>.</p>
<pre><code>set.seed(1)
rbernoulli(5, 0.7)
#> [1] FALSE  TRUE  TRUE  TRUE FALSE
set.seed(1)
rbernoulli(5, 0.7)
#> [1] FALSE  TRUE  TRUE  TRUE FALSE</code></pre>
<p>So it seems like Hadley managed to get <code>set.seed()</code> to work with <code>rbernoulli()</code>. How did he do this? Let’s take a closer look at <code>purrr::rbernoulli()</code>.</p>
<pre><code>purrr::rbernoulli
#> function (n, p = 0.5) 
#> {
#>     stats::runif(n) > (1 - p)
#> }
#> </code></pre></div>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/rstudio-connect-1-6-8-emails-apis-and-titles/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://blog.rstudio.com/2018/09/20/rstudio-connect-1-6-8-emails-apis-and-titles/"> RStudio Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>RStudio Connect 1.6.8 includes additions to custom emails, new user endpoints in the RStudio Connect Server API, support for content descriptions and title changes, and important security and authentication improvements.</p>
<p>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/taking-a-tour-of-the-pirate-ship-github-dmca-with-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rud.is/b/2018/09/19/taking-a-tour-of-the-pirate-ship-github-dmca-with-r/"> R – rud.is</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Despite having sailed through the core components of this year’s <a rel="nofollow" href="http://talklikeapirate.com/wordpress/" target="_blank">Talk Like A Pirate Day</a> R post a few months ago, time has been an enemy of late so this will be a short post that others can build off of, especially since there’s lots more <strike>knife work</strike> ground to cover from the data.</p>
<h3>DMC-WhAt?</h3>
<p>Since this is TLAPD, I’ll pilfer some of the explanation from GitHub itself:</p>
<p>The Digital Millennium Copyright Act (DMCA) <span></span>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/animating-the-premier-league-using-gganimate/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.jumpingrivers.com/blog/r-gganimate-premier-league/"> r – Jumping Rivers</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Ever wonder what an evolving gif of each premier league team's goal difference vs points would look like made in R? Look no further! Most of this is going to be setting up the data (as always) instead of actually plotting the data. To get the data into shape, we’re going to be using the <strong>tidyverse</strong> and <strong>lubridate</strong>, which you can install the usual way via <code>install.packages()</code>. To animate the data we’ll be using the <strong>gganimate</strong> package. This is not on CRAN and so must be installed from GitHub, which you can do so via the <strong>devtools</strong> package</p>
<pre><code>devtools::install_github(&quot;thomasp85/gganimate&quot;)
</code></pre>
<p>To get started let's attach the relevant packages</p>
<pre><code>library(&quot;tidyverse&quot;)
library(&quot;lubridate&quot;)
library(&quot;gganimate&quot;)
</code></pre>
<p>We're going to use the last full season of matches in the premier league, which was the 17/18 season. The data was sourced from <a rel="nofollow" href="http://football-data.co.uk/" target="_blank">football-data.co.uk</a></p>
<pre><code>prem = read_csv(&quot;http://www.football-data.co.uk/mmz4281/1718/E0.csv&quot;)
head(prem)

## # A tibble: 6 x 65
##   Div   Date  HomeTeam AwayTeam  FTHG  FTAG FTR    HTHG  HTAG HTR   Referee
##   </code></pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/analysis-of-los-angeles-crime-with-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://datascienceplus.com/analysis-of-los-angeles-crime-with-r/"> R Programming â€“ DataScience+</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>City of Los Angeles or “The Birthplace of Jazz” is one of the most populous city in the United States of America with the population estimated over four million. With the city of this size, it is worth the effort to explore the crime rate in this city.</p>
<p>The current project is aimed to explore the crime rate in the year 2017. The dataset used in this project is found in this <a rel="nofollow" href="https://data.lacity.org/A-Safe-City/Crime-Data-from-2010-to-Present/y8tr-7khq" target="_blank">link</a> which is provided by the Los Angeles Police Department. </p>
<h2>Date Preparation</h2>
<pre><code>library(data.table) #faster way to read large dataset
library(tidyverse) #load dplyr, tidyr and ggplot
library(ggmap) #use to read map
library(maps) #map tools kits
library(mapdata) #read the map data
library(lubridate) #date manuplation
library(ggrepel) #better label
library(varhandle) #load the function unfactor

crime_la &lt;- as.data.frame(fread(&quot;Crime_Data_from_2010_to_Present.csv&quot;, na.strings = c(&quot;NA&quot;)))
glimpse(crime_la)</code>
<em>## Observations: 1,805,537
## Variables: 26
## $ `DR Number` </em></pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/mapping-the-stock-market-using-self-organizing-maps/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://databasedinvesting.blogspot.com/2018/08/mapping-stock-market-using-self.html"> Data based investing</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>Self-organizing maps are an unsupervised learning approach for visualizing multi-dimensional data in a two-dimensional plane. They are great for clustering and finding out correlations in the data. In this post we apply self-organizing maps on historical US stock market data to find out interesting correlations and clusters. We’ll use data from <a rel="nofollow" href="http://www.econ.yale.edu/~shiller/data.htm" target="_blank">Shiller</a>, <a rel="nofollow" href="http://www.hec.unil.ch/agoyal/" target="_blank">Goyal</a> and <a rel="nofollow" href="https://data.bls.gov/timeseries/LNS14000000" target="_blank">BLS</a> to calculate the historical valuations levels, interest rates, inflation rates, unemployment rates and future ten-year total real returns from years 1948 to 2008.<br><img border="0" src="https://i2.wp.com/4.bp.blogspot.com/-SY6Ntl0Jz7k/W2igtWoG8mI/AAAAAAAAABY/wMIhNDsqDM4nYZiPF6HR8zsxOLXArV_tgCLcBGAs/s320/icon2.PNG?resize=450%2C316&ssl=1" data-original-width="450" width="450" data-original-height="316" data-recalc-dims="1"></div>
<div><b>Click to enlarge images</b><br></div>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/continuous-deployment-of-package-documentation-with-pkgdown-and-travis-ci/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.datacamp.com/community/blog/cd-package-docs-pkgdown-travis"> DataCamp Community - r programming</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>The problem</h2>
<p>pkgdown is an R package that can create a beautifully looking website for your own R package. Built and maintained by Hadley Wickham and his gang of prolific contributors, this package can parse the documentation files and vignettes for your package and builds a website from them with a single command: <code>build_site()</code>. <a rel="nofollow" href="https://datacamp.github.io/testwhat/" target="_blank">This is what such a pkgdown-generated website looks like in action</a>.</p>
<p>The html files that pkgdown generated are stored in a <code>docs</code> folder. If your source code is hosted on GitHub, you just have to commit this folder to GitHub, navigate to the Settings panel of your GitHub repo and enable GitHub pages to host the <code>docs</code> folder at <code>https://</code>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/let-r-python-send-messages-when-the-algorithms-are-done-training/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.theanalyticslab.nl/2018/06/24/telegram-messages/"> Rbloggers – The Analytics Lab</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>As Data Scientists, we often train complex algorithms in order to tackle certain business problems and generate value. These algorithms, however, can take a while to train. Sometimes they take a couple of hours, hours which I’m not going to spend just sitting and waiting. But regularly checking whether the training is done, is also not the most efficient way.</p>
<p>Now I started to use Telegram to send me notifications from R and Python to let me know when training is done. Furthermore, I’m also using it for example to send me notifications when pipelines / ETLs fail, which allows me to repair them as soon as they fail.</p>
<p>It’s really easy, so I thought I’ll share my code!</p>
<p>First, after you’ve installed Telegram, search for the BotFather, which is a bot from the app itself. When you text <em>/newbot</em>, and follow the instructions, it will create your first bot and gives you a token. Copy this!</p>
<p>Next step is to find the id to send messages to. Find your bot in Telegram and say something. Then, go to your browser and go to <a rel="nofollow" href="https://api.telegram.org/bot%3Ctoken%3E/getUpdates" target="_blank">https://api.telegram.org/bot</a>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/the-ssh-package-secure-shell-ssh-client-for-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://ropensci.org/technotes/2018/06/12/ssh-02/"> rOpenSci - open tools for open science</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p> <img alt="cover image" src="https://i0.wp.com/upload.wikimedia.org/wikipedia/commons/d/d7/8-cell.gif?w=456&ssl=1" data-recalc-dims="1"></p>
<p>Have you ever needed to connect to a remote server over SSH to transfer files via SCP or to setup a secure tunnel, and wished you could do so from R itself? The new rOpenSci <a rel="nofollow" href="https://cran.r-project.org/web/packages/ssh/index.html" target="_blank">ssh</a> package provides a native ssh client in R allows you to do that and even more, like running a command or script on the host while streaming stdout and stderr directly to the client. The package is based on <a rel="nofollow" href="https://www.libssh.org/" target="_blank">libssh</a>, a powerful C library implementing the SSH protocol.</p>
<pre><code>install.packages(&quot;ssh&quot;)
</code></pre>
<p>Because the ssh package is based on libssh it does not need to shell out. Therefore it works natively on all platforms without any runtime dependencies. Even on Windows.</p>
<p>The package is still work in progress, but the core functionality should work. Below some examples to get you started from the <a rel="nofollow" href="https://cran.r-project.org/web/packages/ssh/vignettes/intro.html" target="_blank">intro vignette</a>.</p>
<h2>Connecting to an SSH server</h2>
<p>First create an ssh session by connecting to an SSH server.</p>
<pre><code>session &lt;- ssh_connect(&quot;jeroen@dev.opencpu.org&quot;)
print(session)

## </code></pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/workaround-for-tidyrspread-with-duplicate-row-identifiers/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.daeconomist.com/post/2018-05-15-spread/"> Digital Age Economist on Digital Age Economist</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>The problem</h2>
<p>The <code>tidyverse</code> api is one the easiest APIs in <code>R</code> to follow – thanks the concept of grammer based code. But every now and again you come across an error that boggles your mind, my personal one is the error spread delivers when I have no indexing for my data: <code>Error: Duplicate identifiers for rows (2, 3), (1, 4, 5)...</code>. I am sure we have all seen this some or other time.</p>
<p>Well, lets reproduce this error:</p>
<pre><code>library(dplyr)
library(tidyr)
df
</code></pre>
<pre><code>## # A tibble: 5 x 2
##   age   gender
##   </code></pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/get-your-tracks-from-the-strava-api-and-plot-them-on-leaflet-maps/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://rcrastinate.blogspot.com/2018/05/get-your-tracks-from-strava-api-and.html"> Rcrastinate</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Here is some updated R code from my <a rel="nofollow" href="http://rcrastinate.blogspot.de/2018/01/where-do-you-run-to-map-your-strava.html" target="_blank">previous post</a>. It doesn’t throw any warnings when importing tracks with and without heart rate information. Also, it is easier to distinguish types of tracks now (e.g., when you want to plot runs and rides separately). Another thing I changed: You get very basic information on the track when you click on it (currently the name of the track and the total length).</p>
<p>Have fun and leave a comment if you have any questions.</p>
<div><a rel="nofollow" href="https://i2.wp.com/2.bp.blogspot.com/-602gK0AN3HM/Wugy8RJe1oI/AAAAAAAADQc/vd8HvXNqv5sJnX0E0Nb5dRVwsOZecsuTwCLcBGAs/s1600/network.PNG?ssl=1" target="_blank"><img border="0" src="https://i0.wp.com/2.bp.blogspot.com/-602gK0AN3HM/Wugy8RJe1oI/AAAAAAAADQc/vd8HvXNqv5sJnX0E0Nb5dRVwsOZecsuTwCLcBGAs/s400/network.PNG?resize=450%2C1015&ssl=1" data-original-width="450" width="450" data-original-height="1015" data-recalc-dims="1"></a></div>
<p><span><span>options(stringsAsFactors = F)
<p>rm(list=ls())</p>
<p>library(httr)<br>library(rjson)<br>library(leaflet)<br>library(dplyr)</p>
<p>token &lt;-“</span></span>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/get-basic-summary-statistics-for-all-the-variables-in-a-data-frame/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.brodrigues.co/blog/2018-04-10-brotools_describe/"> Econometrics and Free Software</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I have added a new function to my <code>{brotools}</code> package, called <code>describe()</code>, which takes a data frame as an argument, and returns another data frame with descriptive statistics. It is very much inspired by the <a rel="nofollow" href="https://github.com/ropenscilabs/skimr" target="_blank"><code>{skmir}</code></a> package but also by <a rel="nofollow" href="https://github.com/bjornerstedt/assist/blob/master/R/describe.R" target="_blank"><code>assist::describe()</code></a> (click on the packages to be redirected to the respective Github repos) but I wanted to write my own for two reasons: first, as an exercice, and second I really only needed the function <code>skim_to_wide()</code> from <code>{skimr}</code>. So instead of installing a whole package for a single function, I decided to write my own (since I use <code>{brotools}</code> daily).</p>
<p>Below you can see it in action:</p>
<pre><code>library(dplyr)
data(starwars)</code></pre>
<pre><code>brotools::describe(starwars)</code></pre>
<pre><code>## # A tibble: 13 x 12
##    variable   type     mean    sd mode        min   max   q25 median   q75
##    </code></pre>
<p>For some reason, I am unable to load this post to google blogger. I have linked the post to an html file on my home page. Please comment here on this blog.<br> Here is the post:<br> <a rel="nofollow" href="http://www.ling.uni-potsdam.de/~vasishth/slog/pvalsnull2.html" target="_blank">Posterior probability of the null hypothesis being true, given a significant effect</a> </p>
	<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/fY6jPS3EDy4" height="1">
<p>If you still follow my Twitter feed – I pity you, as it’s been rather boring of late. Consisting largely of Github commit messages, many including the words “knit to github document”.</p>
<p>Here’s why. <a rel="nofollow" href="http://rpubs.com/" target="_blank">RPubs</a>, an early offering from RStudio, has been a great platform for easy and free publishing of HTML documents generated from RMarkdown and written in RStudio. That said, it’s always been very basic (<em>e.g.</em> no way to organise documents by content, tags). There’s been no real development of the platform for several years and of late, I’ve noticed it’s become less reliable. Bugs, for example, such as one document overwriting another when published from RStudio.</p>
<p>I think it’s unlikely that issues will be addressed, given that RStudio are now focused on RStudio Connect. So I’ve removed as many documents as I can and rewritten them as <a rel="nofollow" href="https://rmarkdown.rstudio.com/github_document_format.html" target="_blank">Github documents</a>. These render as HTML when pushed to Github, generating attractive reports. <a rel="nofollow" href="https://github.com/neilfws/PubMed/blob/master/commons/code/R/pubmedcommons.md" target="_blank">Here’s an example</a>.</p>
<p>I’ve done my best to update all blog posts here with links to the new reports. If you do come across old broken links to RPubs reports, just remember that the content is probably <a rel="nofollow" href="https://github.com/neilfws?tab=repositories" target="_blank">now at Github</a>.</p>
<p>I’ve left a small number of reports <a rel="nofollow" href="http://rpubs.com/neilfws" target="_blank">at RPubs</a> for now – these ones are interactive and use Javascript-based libraries such as Highcharter or Leaflet.</p>
	<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/sYYSKgMfT3s" height="1">
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/r-tip-use-named-vectors-to-re-map-values/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.win-vector.com/blog/2018/03/r-tip-use-named-vectors-to-re-map-values/"> R – Win-Vector Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Here is an <a rel="nofollow" href="https://www.r-project.org/" target="_blank">R</a> <a rel="nofollow" href="http://www.win-vector.com/blog/tag/r-tips/" target="_blank">tip</a>. Want to re-map a column of values? Use a named vector as the mapping.</p>
<p><span></span></p>
<p>Example:</p>
<pre>
library(&quot;dplyr&quot;)
library(&quot;wrapr&quot;)

head(starwars[, qc(name, gender)])

# # A tibble: 6 x 2
# name           gender
# </pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/r-tip-use-let-to-re-map-names/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.win-vector.com/blog/2018/03/r-tip-use-let-to-re-map-names/"> R – Win-Vector Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Another <a rel="nofollow" href="https://www.r-project.org/" target="_blank">R</a> <a rel="nofollow" href="http://www.win-vector.com/blog/tag/r-tips/" target="_blank">tip</a>. Need to replace a name in some R code or make R code re-usable? Use <a rel="nofollow" href="https://winvector.github.io/wrapr/reference/let.html" target="_blank"><code>wrapr::let()</code></a>.</p>
<p><center><br>
<a rel="nofollow" href="https://cran.r-project.org/package=wrapr" target="_blank"><img src="https://i2.wp.com/www.win-vector.com/blog/wp-content/uploads/2017/08/wraprs.png?w=660" data-recalc-dims="1"></a><br>
</center></p>
<p><span></span></p>
<p>Here is an example involving <a rel="nofollow" href="https://cran.r-project.org/package=dplyr" target="_blank"><code>dplyr</code></a>.</p>
<p>Let’s look at some example data:</p>
<pre>
library(&quot;dplyr&quot;)
library(&quot;wrapr&quot;)

starwars %>%
  select(., name, homeworld, species) %>%
  head(.)

# # A tibble: 6 x 3
# name           homeworld species
# </pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/on-mimes-software-versions-and-web-site-promiscuity-a-k-a-three-new-packages-to-round-out-the-week/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rud.is/b/2018/03/23/on-mimes-software-versions-and-web-site-promiscuity-a-k-a-three-new-packages-to-round-out-the-week/"> R – rud.is</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>A quick Friday post to let folks know about three in-development R packages that you’re encouraged to poke the tyres o[fn] and also jump in and file issues or PRs for.</p>
<h3>Alleviating aversion to versions</h3>
<p>I introduced a “version chart” in a <a rel="nofollow" href="https://rud.is/b/2018/03/07/handling-semantic-version-string-like-a-boss-with-the-semver-package/" target="_blank">recent post</a> and one key element of tagging years (which are <em>really</em> helpful to get a feel for scope of exposure + technical/cyber-debt) is knowing the dates of product version releases. You can pay for such a database but it’s also possible to cobble one together, and that activity will be much easier as time goes on with the <a rel="nofollow" href="https://github.com/hrbrmstr/vershist" target="_blank"><code>vershist</code><img alt="🔗" src="https://i2.wp.com/s.w.org/images/core/emoji/2.4/72x72/1f517.png?w=456&ssl=1" class="wp-smiley" data-recalc-dims="1"></a> package.</p>
<p>Here’s a sample:</p>
<pre><code>apache_httpd_version_history()
## # A tibble: 29 x 8
##    vers   rls_date   rls_year major minor patch prerelease build
##    </code></pre>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/r-tip-use-stringsasfactors-false/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.win-vector.com/blog/2018/03/r-tip-use-stringsasfactors-false/"> R – Win-Vector Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://www.r-project.org/" target="_blank">R</a> <a rel="nofollow" href="http://www.win-vector.com/blog/tag/r-tips/" target="_blank">tip</a>: use <code>stringsAsFactors = FALSE</code>.</p>
<p>R often uses a concept of <code>factor</code>s to re-encode strings. This can be too early and too aggressive. Sometimes a string is just a string.</p>
<p><center><br>
<img border="0" src="https://i1.wp.com/www.win-vector.com/blog/wp-content/uploads/2018/03/800px-Sigmund_Freud_by_Max_Halberstadt_cropped.jpg?resize=441%2C600" alt="800px Sigmund Freud by Max Halberstadt cropped" width="441" title="800px-Sigmund_Freud,_by_Max_Halberstadt_(cropped).jpg" data-recalc-dims="1" height="600">
<p>
<p>Sigmund Freud, it is often claimed, said: “Sometimes a cigar is just a cigar.”<br>
</p>
<p><span></span></p>
<p>To avoid problems delay re-encoding of strings by using <code>stringsAsFactors = FALSE</code> when creating <code>data.frame</code>s.</p>
<p>Example:</p>
<pre>
d &lt;- data.frame(label = rep(&quot;tbd&quot;, 5))

d$label[[2]] &lt;- &quot;north&quot;
#> Warning in `[[&lt;-.factor`(`*tmp*`, 2, value = structure(c(1L, NA, 1L, 1L, :
#> invalid factor level, NA generated

print(d)
#>   label
#> 1   tbd
#> 2  </pre></center>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/installing-package-dependencies-without-external-https-requests/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.peteredewitt.com/dewittpe.github.io/dewittpe.github.io/2018/installing-dependencies/"> Peter E. DeWitt</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Consider you have a server that is running behind a firewall and, for security<br>
reasons, cannot make external http(s) requests. Further, you have R running on<br>
this server and you need to install a set of packages. The simple approach of</p>
<div>
<div>
<pre><code>install.packages(&quot;</code></pre></div></div>
<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/our-logo-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.jumpingrivers.com/posts/2018/logo_in_r/"> R on The Jumping Rivers Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Hi all, so given our logo here at Jumping Rivers is a set of lines designed to look like a Gaussian Process, we thought it would be a neat idea to recreate this image in R. To do so we’re going to need a couple packages. We do the usual <code>install.packages()</code> dance (remember this step can be performed in <a rel="nofollow" href="http://blog.jumpingrivers.com/posts/2017/speed_package_installation/" target="_blank">parallel</a>)</p>
<pre><code>install.packages(c(&quot;ggplot2&quot;, &quot;ggalt&quot;, &quot;readr&quot;))</code></pre>
<p>We’re also going to need the data containing the points for the lines and which set of points belongs to which line. There is a Gist available to download via <a rel="nofollow" href="https://gist.github.com/jumpingrivers/6e88357ef28697c612bb5553251a473d" target="_blank">Jumping Rivers</a>. To read in the csv file we’re going to use the raw data link.</p>
<pre><code>(dd = readr::read_csv(&quot;https://goo.gl/HzNbAp&quot;, col_types = &quot;ddc&quot;))
## # A tibble: 40 x 3
##       x     y type 
##   </code></pre>