<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>R on Tom Roth</title><link>https://tomroth.dev/tags/r/</link><description>Recent content in R on Tom Roth</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Tue, 09 May 2017 00:00:00 +0000</lastBuildDate><atom:link href="https://tomroth.dev/tags/r/index.xml" rel="self" type="application/rss+xml"/><item><title>Understanding Kadane’s solution to the maximum subarray problem</title><link>https://tomroth.dev/kadane/</link><pubDate>Tue, 09 May 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/kadane/</guid><description>There is something called the maximum subarray problem, and it goes something like this.
You are given an array of numbers: something like 3,5,-2,-1,5,3,1,-4,-6,5. Your job is to come up with the subarray with the highest sum.
For this example it would be the subarray [3,5,-2,-1,5,3,1], which has a sum of 14. No other subarray gives a higher sum.
Let&amp;rsquo;s look at a few more:
The sequence -3,-3,-2,-4,-2,-5,-4 has the highest sum being -2, given by the subarray [-2].</description></item><item><title>Mean, median, or mode? When to use each of them.</title><link>https://tomroth.dev/median/</link><pubDate>Wed, 03 May 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/median/</guid><description>Pretend you wish to get an idea of the average value of your dataset. You&amp;rsquo;ve got a few choices available to you, of which the most common three are the mean, median and mode.
You might argue that the mode is a better choice than the median and the mean, mostly based on the below graphic.
But the mode suffers from other problems. It will fail you on an exponential distribution, or on a log distribution.</description></item><item><title>Integrating Javascript and d3 into R notebooks</title><link>https://tomroth.dev/r-d3/</link><pubDate>Thu, 13 Apr 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/r-d3/</guid><description>Recently the team over at RStudio released R Notebooks.
R Notebooks are really interesting. Here&amp;rsquo;s why:
You can write code in several different languages in one document (including python, bash, dot, ruby, javascript, sql) You can write in Markdown You can write in HTML You can see your code as it runs Writing reproducible code is easier It&amp;rsquo;s easy to share code results with others It&amp;rsquo;s the intertwining of languages bit that interests me the most.</description></item><item><title>Three simple matrix decompositions in R</title><link>https://tomroth.dev/decomp/</link><pubDate>Sun, 11 Dec 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/decomp/</guid><description>In the confusing world of matrix decompositions, three of the most useful are $A = LU$, $A = U^T U$ (the Cholesky decomposition) and $A = QR$.
Here&amp;rsquo;s some R code to explore these useful beasts.
1. A = LU Link to heading Present in every textbook in linear algebra, performing LU decompositions in R is quick and painless.
The easiest way to do this is to use the lu function in the Matrix package.</description></item><item><title>Write your own logistic regression function in R</title><link>https://tomroth.dev/logistic/</link><pubDate>Wed, 05 Oct 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/logistic/</guid><description>Ever wondered how logistic regression really works?
You&amp;rsquo;re not alone. It&amp;rsquo;s confusing.
This post drills down into the mechanics of logistic regression. We&amp;rsquo;ll go through the mathematical aspects and also construct our own logistic regression function in R. Exciting!
What is logistic regression? Link to heading In linear regression the dependent variable $Y$ takes continuous values, like house prices for an area or the income of a individual.
Logistic regression differs in that it is used for modelling categorical data.</description></item><item><title>Linear Regression in R</title><link>https://tomroth.dev/regression/</link><pubDate>Sun, 07 Aug 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/regression/</guid><description>As humans, we&amp;rsquo;re drawn to cause and effect. Even when it&amp;rsquo;s wrong of us to do so.
When it gets hot, it&amp;rsquo;s not necessarily because of global warming. An increase in homeless people will not definitively cause an increase in crime rates. Male drivers crash more than female drivers, but maybe this isn&amp;rsquo;t because of their increased testosterone levels.
We&amp;rsquo;ve all heard the correlation vs causation argument before. Our System 2 conscious mind knows that cause and effect isn&amp;rsquo;t always correct.</description></item></channel></rss>