<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Yes R Can - Medium]]></title>
        <description><![CDATA[“There is a package for that” - Medium]]></description>
        <link>https://medium.com/yes-r-can?source=rss----bffa0927ae4a---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Yes R Can - Medium</title>
            <link>https://medium.com/yes-r-can?source=rss----bffa0927ae4a---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:08:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/yes-r-can" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[R in the Cloud]]></title>
            <link>https://medium.com/yes-r-can/r-in-the-cloud-e4754d505a6?source=rss----bffa0927ae4a---4</link>
            <guid isPermaLink="false">https://medium.com/p/e4754d505a6</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[digitalocean]]></category>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Berk Orbay]]></dc:creator>
            <pubDate>Tue, 09 May 2017 16:01:18 GMT</pubDate>
            <atom:updated>2017-05-09T16:01:17.533Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*W-cYw7RcGSuwoPimTs3c0g.jpeg" /></figure><p><em>About deploying R and R Studio on cloud servers. Digital Ocean is the first tutorial. Soon, AWS. Btw, If you don’t know about </em><a href="https://www.youtube.com/watch?v=NNiie_zmSr8"><em>Eye in the Sky</em></a><em> by Alan Parsons Project, please listen.</em></p><p>I know, there are many tutorials on putting R and R Studio on the cloud, especially Digital Ocean. Mine even can be a copycat (let me list some sources at the bottom to ease my conscience). Though, I keep losing the sources. Therefore, I made my own and share it with you. Once you have a DO account, the rest takes less than 5 minutes and 5 lines of code. <strong>Actually, it is easier than setting up R and R Studio locally.</strong></p><p>Once you are set, you will have an R Studio instance that can be reachable via a web browser. It means you can “run” R on your tablet or mobile phone. It is incredibly useful for other purposes as well.</p><p>Although there are other methods, the easiest way goes through using <a href="https://hub.docker.com/r/rocker/">rocker</a> (a Docker container). <em>Do not download it, I added the link just for the information.</em></p><p>See the tutorial <a href="http://berkorbay.me/documents/R_on_cloud.html">here</a>, enjoy.</p><p><em>ps. pdf version can also be found on the main site</em></p><h4>Other Sources</h4><ul><li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-16-04-2">https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-16-04-2</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-rstudio-on-an-ubuntu-cloud-server">https://www.digitalocean.com/community/tutorials/how-to-set-up-rstudio-on-an-ubuntu-cloud-server</a></li><li><a href="http://keeganhin.es/blog/docker.html">http://keeganhin.es/blog/docker.html</a></li><li><a href="http://matthewlincoln.net/2015/08/31/setup-rstudio-and-shiny-servers-on-digital-ocean.html">http://matthewlincoln.net/2015/08/31/setup-rstudio-and-shiny-servers-on-digital-ocean.html</a></li><li><a href="http://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/">http://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/</a></li><li><a href="https://github.com/sckott/analogsea">https://github.com/sckott/analogsea</a></li><li><a href="https://www.r-statistics.com/2015/06/setting-rstudio-server-using-amazon-web-services-aws-a-step-by-step-screenshots-tutorial/">https://www.r-statistics.com/2015/06/setting-rstudio-server-using-amazon-web-services-aws-a-step-by-step-screenshots-tutorial/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4754d505a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yes-r-can/r-in-the-cloud-e4754d505a6">R in the Cloud</a> was originally published in <a href="https://medium.com/yes-r-can">Yes R Can</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why You Should Build That R Package Already (Especially for Grad Students)]]></title>
            <link>https://medium.com/yes-r-can/why-you-should-build-that-r-package-already-especially-for-grad-students-205e783d1230?source=rss----bffa0927ae4a---4</link>
            <guid isPermaLink="false">https://medium.com/p/205e783d1230</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[graduate-school]]></category>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Berk Orbay]]></dc:creator>
            <pubDate>Mon, 01 May 2017 07:28:06 GMT</pubDate>
            <atom:updated>2017-05-01T07:27:53.071Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mps2LCRU-7PC_7dpeWJSKg.png" /></figure><p>Scores of people use R in their professional or academic endeavors, and many others join the club each day. R is increasingly the best choice for getting the job done in a fast and elaborate way.</p><p>This post is not a direct rant about R, but it is written to urge somewhat non-beginner R users (i.e. say, you are non-beginner if you started using R as a regular part of your day) to start working on their packages. A rite of passage, one might daresay.</p><blockquote>You should turn that spaghetti of a code of yours into an R package ASAP.</blockquote><p>Without further ado, here is the pitch. It is a good pitch. It is the best pitch, believe me. Those who do not follow my words are pathetic. SAD. <em>(I probably shouldn’t have written that, but whatever I’m keeping it.)</em></p><p><strong>“OK, I am already sold. Show me the way.”</strong> The reasons I am about to describe uses the procedure building your package using <em>devtools</em> and <em>roxygen2</em> packages, and using GitHub. Sure, there are other ways but that was the most convenient to me. Start from here: <a href="https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/">[1]</a>, <a href="http://kbroman.org/pkg_primer/">[2]</a>, <a href="https://education.github.com/pack">[3]</a>, <a href="https://desktop.github.com/">[4]</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*sjwRMMAAoOMzqAxiC0ISbQ.png" /><figcaption>Portability</figcaption></figure><h3>Reason 1: Portability</h3><p><strong>All your code, at your service, with a single line of code</strong> of <em>library(myabstrusepackagename)</em>. You can take it to any machine easily and if you use GitHub as a repository, just download it using <em>devtools::install_github. It works like a charm, your research goes with you to everywhere.</em></p><h3>Reason 2: Reproducibility</h3><p>Ok, despite the late surge of interest, <strong>reproducibility is still a hipster thing</strong>. Reproducibility can be defined as “If I repeat your experiment with your methodology and with your data, I should come to your exact conclusions. If I repeat your experiment with your methodology and with my data, I should come up with similar conclusions.” Fundamental scientific property.</p><p>Today’s academic world is filled with noise (i.e. irreproducible studies). Perhaps, <em>publish or perish</em> rule is to blame. This is not a piece about reproducibility in science, so I will just drop it <a href="http://www.nature.com/news/1-500-scientists-lift-the-lid-on-reproducibility-1.19970">here</a>.</p><p>Dealing with somebody else’s data and code is the utter nightmare. But also, your study should be reproducible so others can confirm your results and build on it (and citations will come). You should make it easy for others to use your research. <strong>Your R package is the way to establish reproducibility.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*W0ECMQGP4xEWJEtbJDc5kw.jpeg" /><figcaption>Convenience and Order</figcaption></figure><h3>Reason 3: Convenience &amp; Order</h3><p>No more different versions of the same .R files in the same directory (you can use branches instead if you know your way around Git). No more code in different directories. No more lost code in your hard drive or flashdisk, written in a burst of productivity. It also urges you to write better, more careful and with more planning ahead. These are extremely good traits of a work often sacrificed for speed or experimentation.</p><p><strong>Just code for the package, follow simple rules, easily build your pipeline.</strong></p><h3>Reason 4: Documentation &amp; Presentation</h3><p>One of the best properties of R was calling the immediate help function with ? and the function name e.g. <em>?thefunctionididntknowabout</em>. With the help of <em>roxygen2</em> package, you can write documentation just above your functions and everything will be sorted out for you!</p><p>You don’t need to write documentation immediately, but you can always write your documentation and it will make it easier for everyone (including you).</p><p>R has also great storytelling tools such as R Markdown and Shiny. You can embed document templates or user interfaces in your package. So, you can demonstrate the power of your work with a single line of code even to those who have no idea about it.</p><blockquote><strong>R has the power of demonstration at the lowest labor cost.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aiBxRnRCFWnoz89D45fuPQ.png" /><figcaption>Product</figcaption></figure><h3>Reason 5: A product (at no marginal cost)</h3><p>This is the biggest reward of all. You are going to have a product which you will use extensively and repeatedly. <strong>No more lost code after you graduate.</strong> You can use it elsewhere, improve it, build on it and always have a working product (old code have the habit of malfunctioning). <strong>Never lose your code again.</strong></p><p>You can then use your product as a foundation stone for your commercial project and even build a startup around it. Integrate your product with other tools. Make it a part of something bigger. You will never ever have to start from scratch again.</p><p>For instance, an educational package I created before helped me (and Nezih) to build another product to create a scenario analysis screen for the Turkish Referendum which predicted the outcome with high accuracy. See the story <a href="https://medium.com/yes-r-can/how-r-and-shiny-helped-predict-turkish-referendum-ffad6c747463">here</a>.</p><h3>Final Say</h3><ul><li>If you are a grad student, start an R package. Demonstrate your work to your thesis supervisor and your peers easily.</li><li>If you are a researcher, start an R package. So, you will not lose track of your research project and always have a reliable tool.</li><li>If you are a professor, ask your students to build an R package. So their progress can be improved, their work can be screened and made reusable.</li></ul><p><em>Also, don’t hesitate to </em><a href="https://www.linkedin.com/in/berkorbay/"><em>contact me</em></a><em> if you have any questions about R and packages. I will be glad to help out.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=205e783d1230" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yes-r-can/why-you-should-build-that-r-package-already-especially-for-grad-students-205e783d1230">Why You Should Build That R Package Already (Especially for Grad Students)</a> was originally published in <a href="https://medium.com/yes-r-can">Yes R Can</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How R and Shiny Helped Predict Turkish Referendum]]></title>
            <link>https://medium.com/yes-r-can/how-r-and-shiny-helped-predict-turkish-referendum-ffad6c747463?source=rss----bffa0927ae4a---4</link>
            <guid isPermaLink="false">https://medium.com/p/ffad6c747463</guid>
            <category><![CDATA[turkey]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[elections]]></category>
            <category><![CDATA[shiny]]></category>
            <dc:creator><![CDATA[Berk Orbay]]></dc:creator>
            <pubDate>Wed, 26 Apr 2017 07:59:38 GMT</pubDate>
            <atom:updated>2017-04-25T20:11:42.428Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*EGA2q3a4SxHhRQz1pfcm9g.png" /></figure><p>Recently Turkey held a referendum on changing its constitution and its type of government by handing more power to the president from the prime minister and the parliament. Official results are yet to be announced, but the legislation passed with 51.4% of the votes (51.2% domestic, 59.5% overseas see the <a href="https://en.wikipedia.org/wiki/Turkish_constitutional_referendum,_2017">Wikipedia article</a> for more detail). That’s important news but that’s not the news. <strong>Our R/Shiny tool predicted the referendum as 50.6% Yes (Evet).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*h2J3OnVpO18gi4hIryP8Cw.png" /><figcaption>Our coverage of referendum on Journo.com.tr</figcaption></figure><p>You can try it <a href="https://berkorbay.shinyapps.io/nisan16/">here</a>. It’s in Turkish (sorry), though easily understandable. About 3.5k people used the tool in the first 10 days, they produced about 12k scenarios yielding to the aggregate result of 50.6%. Here is the full story behind it.</p><h3>Some Background</h3><p>I had an R package called <em>secimler</em> (elections in Turkish) that can be installed via GitHub (<a href="https://berkorbay.github.io/secimler/">see here</a>). The package consists of election results on a ballot basis for the last two general elections in Turkey; November 1, 2015 and June 7, 2015 . It is mainly used for educational purposes to teach data analysis and automated reporting (mainly through tidyverse and Rmarkdown). One day, I thought I can also use Shiny in my works (so far I disregarded it as unnecessary). I started investigating for a side project. It is how referendum scenario analysis was born.</p><blockquote>One day, I thought I can also use Shiny in my works. I started investigating for a side project. It is how referendum scenario analysis was born.</blockquote><p>Though, instead of a simple polling app I wanted a different approach. I had the data from the previous elections. I knew about the significant tendencies. Therefore, I decided to ask what they think about four important factors which could affect the outcome of the referendum, then put their opinions into a model and yield a yes/no (evet/hayır) prediction.</p><p>I asked an experienced friend, <a href="https://www.linkedin.com/in/m-nezih-bilgin-b872b124/">Nezih</a>, to help manage the project and handle the UX design. He also helped greatly to promote the tool. He did his best, but there were limits on Shiny and my proficiency in Shiny.</p><h3>Building the Underlying Model</h3><p>The four factors are <em>the tendency of undecided</em>, <em>the tendency of MHP voters</em> (MHP is a right-wing political party, which the leadership decided to support the constitution change though many followers are skeptical of such change), <em>success of CHP’s campaign</em> (CHP is the main opposition party) and <em>the</em> <em>attendence of HDP voters</em> (HDP is the fourth significant political party mainly focused on the issues of the largest minority group in Turkey, Kurds).</p><p>Apparently I was on the right track. Right after the election Ipsos held a similar research and published on Hurriyet &amp; CNN Turk (news outlets).</p><h3>Hurriyet.com.tr on Twitter</h3><p>16 Nisan referandumundan sonra yapılan ilk anket çok çarpıcı sonuçlar veriyor @MuratYetkin2 yazdı... https://t.co/IH2vqRFxc6</p><p>I had the data from the last two elections, so I could build a numeric model to spit out predictions not only for the whole country but also individual cities (though, most of the interest was on country-wise predictions).</p><p>The model I built was some ad-hoc model with lots of “educated guesses”. Admittedly, it had no scientific foundations (no accepted prediction model in the literature is used, <em>as if they would work</em>). A model is only as good as its assumptions, and I believe I made some good ones which brought the increased accuracy.</p><p>I assumed vote swings between the previous two elections as the undecided as there were only 6 months between those two elections with a significant difference (btw, <a href="https://www.bloomberg.com/news/articles/2016-07-16/turkey-coup-attempt-how-it-unfolded-and-how-it-failed">much happened</a> since the last election). I also introduced some <em>bias </em>in the results for two reasons: First, my audience was not homogeneous or necessarily objective. Second, there might indeed be some “bias” in the vote counting. So skewing the input metrics (e.g. mid-point is not actually a mid-point) a bit helped the model to achieve better accuracy.</p><p><strong>I will add the calculations and the Shiny codes to <em>secimler</em> package with the collected data from the users, so you will be able replicate the results.</strong></p><h3>Building the App</h3><p>Building the app on Shiny was fairly easy. It took me half a day to get the basics and build a working prototype and 2 more days to do fine tuning to finish. The outcome was a marvelous (and responsive) website built with only R!</p><blockquote>The outcome was a marvelous (and responsive) website built with only R!</blockquote><p>Shiny is a great tool to rapidly build a product. Though, it is not easily customizable or it is not great on production ready peripheral tools. I had to hack my way into changing slider labels, I had to hardcode some tracking tools (Google Analytics and Facebook Pixel) and I had to <a href="http://stackoverflow.com/questions/36129522/show-loading-graph-message-in-plotly">manually define</a> “loading” UI elements. Little but nice details. I hosted it on <a href="http://shinyapps.io/">Shinyapps.io</a>, which turned out to be a reliable service. I used Google Drive for <a href="https://shiny.rstudio.com/articles/persistent-data-storage.html">data storage</a>.</p><p>Nezih provided amazing help in testing the app and guiding the UI and UX of the project. He made the interface much more understandable and intuitive. Without him, this project would be much less effective.</p><h3>Reception and Results</h3><p>We promoted the app through our Facebook, Linkedin and Twitter accounts. I also spent some money on some fine arranged Facebook advertising with quite a modest budget (~100 TL / 35$). Thanks to Nezih’s efforts, we had two articles on Journo (<a href="https://journo.com.tr/16-nisan-referandumu-tahmin-araci">the introduction</a> and <a href="https://journo.com.tr/referandum-tahmin-araci-ilk-sonuclar">the analysis</a>). About 3.5k people used the tool (according to GA data) and they made about 12k scenarios. So I cut the advertising at quarter of the budget :) Here is the scenario distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qZxnBleKVXa5h_X3JI3hCQ.png" /><figcaption>Distribution of Yes/No (Evet/Hayir) scenarios.</figcaption></figure><p>Incidentally, our error rate (0.8% or 0.6% if you just count domestic votes) is quite low compared to other polling firms predicting the referendum results. <a href="https://en.wikipedia.org/wiki/Opinion_polling_for_the_Turkish_constitutional_referendum,_2017">Here</a> are some of their latest predictions .</p><ul><li>ORC (59.4% Yes / 8% error)</li><li>Qriously (59% Yes / 7.6% error)</li><li>A &amp; G (60.8% Yes / 9.4% error)</li><li>THEMIS (46.1% Yes / 5.3% error)</li><li>KONDA (51.5% Yes / 0.1% error) <strong>Congratulations!</strong></li><li>AKAM (46.2% Yes / 5.2% error)</li><li>MAK (56.5% Yes / 5.1% error)</li><li>ANAR (52% Yes / 0.6% error) <strong>Yay!</strong></li><li>Gezici (51.3% Yes / 0.3% error) <strong>Yay!</strong></li><li>Konsensus (48.8% Yes / 2.6% error)</li><li>Sonar (48.8% Yes / 2.6% error)</li><li>CHP (42.3% Yes / 9.1% error)</li><li>Politic’s (55.7% Yes / 4.3% error)</li><li>NET (48.9% Yes / 2.5% error)</li></ul><h3>Conclusions</h3><p>We reached following conclusions with our little experiment.</p><ul><li>R, again, proved to be a great programming language for data tidying and analysis.</li><li>Shiny is a powerful tool for interactive data products. You can build a web tool in almost no time and do something with it.</li><li>Data based predictions can increase the accuracy of predictions. Model building is equally important.</li><li>Turkey’s politics is a good learning opportunity.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffad6c747463" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yes-r-can/how-r-and-shiny-helped-predict-turkish-referendum-ffad6c747463">How R and Shiny Helped Predict Turkish Referendum</a> was originally published in <a href="https://medium.com/yes-r-can">Yes R Can</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blogroll]]></title>
            <link>https://medium.com/yes-r-can/blogroll-b3d261527b50?source=rss----bffa0927ae4a---4</link>
            <guid isPermaLink="false">https://medium.com/p/b3d261527b50</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[blogroll]]></category>
            <dc:creator><![CDATA[Berk Orbay]]></dc:creator>
            <pubDate>Tue, 25 Apr 2017 16:02:31 GMT</pubDate>
            <atom:updated>2017-04-25T16:02:31.447Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a list of R related sources that you can find useful.</p><h3>Basics</h3><p><a href="https://www.r-project.org/">R-project</a>: Official R homepage. You can get the latest news, distributions, events and don’t forget to check out <a href="https://journal.r-project.org/">R Journal</a>.</p><p><a href="https://www.r-bloggers.com/">R-Bloggers:</a> This is a contributed article aggregator about R from various sources. It is highly recommended to join the newsletter, follow Facebook/Twitter accounts.</p><p>To be continued.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3d261527b50" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yes-r-can/blogroll-b3d261527b50">Blogroll</a> was originally published in <a href="https://medium.com/yes-r-can">Yes R Can</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why R is the best programming language (for the rest of us)?]]></title>
            <link>https://medium.com/yes-r-can/why-r-stats-is-the-best-2c09d77de25b?source=rss----bffa0927ae4a---4</link>
            <guid isPermaLink="false">https://medium.com/p/2c09d77de25b</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Berk Orbay]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 12:49:21 GMT</pubDate>
            <atom:updated>2017-04-06T12:49:29.508Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ZeFpYH44Og30FZsQD-pZlg.jpeg" /></figure><p>I am an R user for more than 6 years. My introduction to R was in a PhD course of Monte Carlo Simulation in Finance by Wolfgang Hörmann. I have previous experience with other languages also; most recent is C++ (which I love, too.) But, none of them are as <strong>convenient</strong> as R.</p><p>Before I start to list why R is the best language for the rest of us, let me clarify the “rest of us” part. We, the Excel users, SPSS users, not computer science (CS) people*; in other terms, “customers of programming” who strive for simplicity, yet search for power and flexibility. R is the best programming language for <strong>us</strong>.</p><p><em>I will make some comparisons with Python because it is the closest peer of R. Sorry in advance, Python users. I love you, too.</em></p><p><em>*Actually, I am a bit of a CS person (but only a bit). Nothing wrong with that :)</em></p><h3>1. Ready for Work</h3><p>Just <a href="https://cloud.r-project.org/">download R</a> and install. You can start programming immediately. Of course, it will be better if you have an editor like Atom or R Studio. But, even without them you are up and running.</p><p>If or when you work with Python, you will see the initialization is not straightforward. You can run from script in Shell or you can use IDLE. You can even use bundlers like Anaconda. Just ask a newbie to install and run some commands in Python.</p><p>Python has also two versions: 2.x and 3.x. Even if they say 3.x is now taking over (naturally) there are loads of stuff depending on 2.x. Confusion starts from the beginning.</p><h3>2. Simplistic Design</h3><p>R language is not initially designed by CS people but statistics people. So, some very convenient conventions for the rest of us can be preposterous to CS people. Let me give you a simple example.</p><p>Suppose we have an “object” which holds letters A-B-C-D-E. Each element of the object holds a letter. Let’s name it as myobject.</p><p>In R, myobject[1] returns “A”. In Python it returns “B” because index starts from 0 in Python. myobject[0] returns “A”. <strong>When I tell CS people R object index starts from 1, they literally gasp. </strong>Let’s say we can be over it. Next is better.</p><p>In R myobject[1:3] returns “A”,“B”,“C”, it literally says index 1 to 3. In Python it returns “B”,“C” because the end point is not included. To get the exact ABC, it should be myobject[0:3]. It will get index 0–1–2, therefore “A”,“B”,“C”. <strong>So, literally WTF?!</strong></p><p>In R myobject[-1] returns all elements except the first one; “B”,“C”,“D”,“E”. In Python, it returns the last item “E”. So, myobject[1] returns the second item but myobject[-1] returns the first item from the end? That’s a bit too much.</p><p>I will not even talk about indentation vs bracketing discussion. In my opinion, brackets are educational and useful. Python forces you to use indentation, but it is not a big deal.</p><p>In a similar fashion R has no “methods” (e.g. object.method()), only functions. Yeah you can define a function in an R object (object$method()) but who does this? You don’t need to.</p><h3>3. Packages</h3><p>You can literally do thousands of stuff in R. For starters, just check the <a href="https://cran.r-project.org/web/views/">Task View</a>. It is not limited to the task view. CRAN (the App Store of R) has more than 10.000 packages right now.</p><p>Whatever you are doing, or need to code, probably there is an R package for that. There are many statistical models and other tools out there for a variety of needs.</p><p>Most of the latest advancements in the literature are presented as R packages. Because installing and loading packages in R is a no-brainer. Plus, you can upload your packages to GitHub.</p><p>CRAN is a high quality repository, therefore package uploading can be painful there. So, many R developers put their packages on GitHub first, then send them to CRAN.</p><p>To install a package just write <em>install.packages(“packagename”)</em> once (it downloads the package and its dependencies) and write <em>library(packagename) </em>to start working with it.</p><h3>4. Documentation and Community</h3><p>R might not have the largest community out there, but it definitely is one of the best. Almost every problem you encounter with R, you can find someone with the same problem on <a href="http://stackexchange.com/">StackExchange</a> or similar platforms. If not, there are more than enough people out there to help you.</p><p>Documentation is also amazing. If you don’t remember the use of a function just put a ? before the name of the function on the console (e.g. <em>?functionname</em>). It will open a help file with the information about the process, parameters and outcomes. At the end, there is also an example section (for the most of them) where you can see how the code works in real time and you can replicate the results.</p><h3>5. Data Structures</h3><p>Data structures in R are pretty easy to comprehend and keep their properties in mind. They also get along quite nice with each other. Sure, vector calculations can be a bit complicated at first, but R allows you to skip vector-mind calculations (at the expense of speed, though).</p><h3>6. tidyverse (especially dplyr &amp; ggplot2)</h3><p>In my opinion <a href="http://tidyverse.org/">tidyverse</a> package is the sweet spot of R. It is actually a meta-package which consists of several packages such as haven, forcats, stringr, tidyr, readr, dplyr and ggplot2. Each of them has great functionality but on the surface two packages are very important. dplyr is for data manipulation and ggplot2 is for plotting. They are quite elegant, unbelievably easy to understand and they have great capabilities that can be expandable with some proficiency or extensions.</p><h3>7. Sick Reporting Features</h3><p>Imagine you have a magic wand that turns code into full featured documents, reports and even books. In R, that wand has several names; rmarkdown, knitr / sweave and bookdown. Those packages with the help of pandoc, you can turn R code into output (pdf, docx, html whatever you like).</p><h3>8. R as an Interface Tool</h3><p>I should admit, R is still in infancy here. But, it has a package that gets the job done at least for prototyping purposes: <a href="https://shiny.rstudio.com/">Shiny</a>. It simply turns your code into an interactive web page.</p><h3>9. Weaknesses</h3><p>Even the weaknesses of R cannot be a reason to not to use.</p><ul><li>R is not well suited to big data projects, because it functions in-memory. So, stuff like writing to and reading from hard disk needs work. That’s ok, because for the most of the cases the provided memory will be enough. If not, then there is always the possibility to set up a VPS and get enough resources.</li><li>Base R does not support parallel programming. Packages that do are limited. That’s also ok because parallel programming requires a special “style”. Since I’m advocating R to non-CS people, they usually don’t care about such stuff.</li><li>R has odd syntax. This one is actually not true. It may be odd to CS people. When I tell the CS people that index starts from 1 not 0, they cringe. Though, it is generally accepted that first element is named 1.</li></ul><h3>10. Final Words</h3><p>Start using R. Start from <a href="https://cloud.r-project.org/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c09d77de25b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yes-r-can/why-r-stats-is-the-best-2c09d77de25b">Why R is the best programming language (for the rest of us)?</a> was originally published in <a href="https://medium.com/yes-r-can">Yes R Can</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>