<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/googleformr-at-work-pneumatic-road-tube-allegory/"></div></div><div><a data-url="http://www.r-bloggers.com/googleformr-at-work-pneumatic-road-tube-allegory/" data-counturl="http://www.r-bloggers.com/googleformr-at-work-pneumatic-road-tube-allegory/" data-count="horizontal" data-text="googleformr at Work: Pneumatic Road Tube Allegory" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://trinkerrstuff.wordpress.com/2016/05/12/googleformr-at-work-pneumatic-road-tube-allegory/"> R – TRinker's R Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a target="_blank" href="http://data-steve.github.io/">Steve Simpson</a> (<a target="_blank" href="https://twitter.com/data_steve">@data_steve</a>) created the <a target="_blank" href="https://github.com/data-steve/googleformr">googleformr</a> package to enable users to easily send information to a Google Form.  It’s a nice way to send and securely store data via R and the price is great…FREE!</p>
<h2>A Pneumatic Road Tube Allegory…Kinda</h2>
<p>My team has been working on a data validation task at work and we’ve built a couple of  internal packages &amp; scripts to help us with the task.  We’ve set it up so non-technical colleagues can use the packages and scripts as automated .bat/.sh files.</p>
<p>After a few months we wanted to make improvements but had no evidence of what packages and scripts were used most often, what parts were worth the additional development time.  What we needed was something like those strips used on streets to determine traffic flow and usage.  Turns out those strips are called <em><a target="_blank" href="http://one-its-webapp1.transport.utoronto.ca/web/one-its/wiki;jsessionid=C774A30DEA94F2DC662BC65780707965?p_p_id=54_INSTANCE_rWJ5&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_54_INSTANCE_rWJ5_struts_action=%2Fwiki_display%2Fview&_54_INSTANCE_rWJ5_nodeName=Main&_54_INSTANCE_rWJ5_title=PNEUMATIC+ROAD+TUBE">pneumatic road tubes</a> </em>in case you ever get that as a Jeopardy question.  They provide a safe, low cost, and simple way to collect information.  Exactly what we needed just a code based version…</p>
<p><img alt="atctop" class="wp-image-2037" src="https://trinkerrstuff.files.wordpress.com/2016/05/atctop.jpg?w=640"></p>
<p>But, like most CRAN mirrors, we <del>have</del> had no way of even knowing when a package is downloaded let alone who’s using the package &amp; scripts and how often.  But once <a target="_blank" href="https://github.com/data-steve/googleformr">googleformr</a> was released that changed.</p>
<p>Our initial phase was just to see who was using the packages/scripts and when.  All that was required to answer this question was (A) making a Google Form with a single text box and then (B) adding a couple of lines of code from <a target="_blank" href="https://github.com/data-steve/googleformr">googleformr</a> to send a unique identifier to a google form (which can be set up to go to a Google Spreadsheet).  A little help from Jenny Bryan’s <a target="_blank" href="https://github.com/jennybc/googlesheets">googlesheets</a> package with some Hadley <a target="_blank" href="https://github.com/hadley/ggplot2">ggplot2</a> love and we had the following image showing employee usage of a particular script for the first several weeks.</p>
<p><strong>I bet you’re asking, “How’d we do it?” Well…  See the explanation and mock code below to make your own code based p<b>neumatic road tube</b>.</strong></p>
<p><img height="561" alt="usage" width="588" class="wp-image-1918" src="https://trinkerrstuff.files.wordpress.com/2016/05/usage.png?w=588&h=561"></p>
<h2>Step 1: Get googleformr</h2>
<p>Getting <a target="_blank" href="https://github.com/data-steve/googleformr">googleformr</a> is simple.  This simple chunk should have you up and running with <a target="_blank" href="https://github.com/data-steve/googleformr">googleformr</a> in a jiffy (do people still say jiffy?):</p>
<pre><code>if (!require(&quot;pacman&quot;)) install.packages(&quot;pacman&quot;)
pacman::p_load_gh(&quot;data-steve/googleformr&quot;)</code></pre>
<h2>Step 2: Make a Google Form</h2>
<p>Then make a Google Form with a text entry.  Here’s an image showing the steps to link the form to a spreadsheet. In the Google Form edit: 1) Click Responses Tab 2) Click those three dot thing-ies 3) Click “Select response destination” 4) click “Create a new spreadsheet”  Step 1 done.  Almost there…</p>
<p><img alt="set_up_spreadsheet" class="wp-image-1945" src="https://trinkerrstuff.files.wordpress.com/2016/05/set_up_spreadsheet.png?w=640"></p>
<p>In this image we see <a target="_blank" href="https://docs.google.com/forms/d/1sLh9CBW7RuzShqnbt260Ud85I_I2qQEdw_S6iMytJx4/viewform?c=0&w=1">the Google Form</a> and the <a target="_blank" href="https://docs.google.com/spreadsheets/d/1spyYSlQ2k0l4wHHODOSYdH8Vxsyal9gQ9FRnhlVr4f0/edit?usp=sharing">accompanying Google Sheet</a>.</p>
<p><img alt="gform" class="wp-image-1937" src="https://trinkerrstuff.files.wordpress.com/2016/05/gform.png?w=640"></p>
<h2>Step 3: Send Information Via googleformr</h2>
<p>Just use the <strong>gformr</strong> function, add the Google Form url (from Step 1) and viola you have  a function that allows you to send information to a Google Form (in this case I made a <strong>ping</strong> function).  This is the function we can use to send information about the package and script usage within our company.</p>
<pre><code>ping &lt;- googleformr::gformr('https://docs.google.com/forms/d/1sLh9CBW7RuzShqnbt260Ud85I_I2qQEdw_S6iMytJx4/prefill')
ping('employee1234')
</code></pre>
<p>You’re in business with a secure way to send data from R to Google Spreadsheet.</p>
<p>Go ahead try it.  Replace ’employee1234′ with whatever you want, go to the <a target="_blank" href="https://docs.google.com/spreadsheets/d/1spyYSlQ2k0l4wHHODOSYdH8Vxsyal9gQ9FRnhlVr4f0/edit#gid=764333400">Google Sheet</a>, and watch the R code you send auto-magically be sent to the spreadsheet. I’ve made this sheet public for demonstration purposes, but generally it’s recommended that you keep the sheets private.</p>
<p>With this simple code snippet placed in the internal scripts and packages we were able to determine what packages and scripts were used, by whom, and how frequently.  So far our pneumatic road tube code  has provided insight into what tools to improve and new features to consider.  And it only took 5 minutes to set up end to end.</p>
<h2>Conclusion</h2>
<p>We’re just getting started with the information we collect to make our internal R tools better.  I think that <a target="_blank" href="https://github.com/data-steve/googleformr">googleformr</a> is an interesting package with a ton of potential for securely sending information for free.  I’d love to hear about your ideas on how to use it via the comments below.</p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/trinkerrstuff.wordpress.com/1877/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/trinkerrstuff.wordpress.com/1877/" border="0"></a> <img height="1" alt="" width="1" src="https://pixel.wp.com/b.gif?host=trinkerrstuff.wordpress.com&blog=35458626&%23038;post=1877&%23038;subd=trinkerrstuff&%23038;ref=&%23038;feed=1" border="0"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/googleformr-at-work-pneumatic-road-tube-allegory/"></div></div><div><a data-url="http://www.r-bloggers.com/googleformr-at-work-pneumatic-road-tube-allegory/" data-counturl="http://www.r-bloggers.com/googleformr-at-work-pneumatic-road-tube-allegory/" data-count="vertical" data-text="googleformr at Work: Pneumatic Road Tube Allegory" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://trinkerrstuff.wordpress.com/2016/05/12/googleformr-at-work-pneumatic-road-tube-allegory/"> R – TRinker's R Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/3qUQ9JMWhgg"></a></div>