Category Archives: Uncategorized

nsaunders's avatarWhat You're Doing Is Rather Desperate

At any R Q&A site, you’ll frequently see an exchange like this one:

Q: How can I use a loop to […insert task here…] ?
A: Don’t. Use one of the apply functions.

So, what are these wondrous apply functions and how do they work? I think the best way to figure out anything in R is to learn by experimentation, using embarrassingly trivial data and functions.

If you fire up your R console, type “??apply” and scroll down to the functions in the base package, you’ll see something like this:

Let’s examine each of those.

1. apply
Description: “Returns a vector or array or list of values obtained by applying a function to margins of an array or matrix.”

OK – we know about vectors/arrays and functions, but what are these “margins”? Simple: either the rows (1), the columns (2) or both (1:2). By “both”, we mean “apply the…

View original post 1,006 more words

Michael Lugo's avatarGod plays dice

People who want to learn the very basics of R may find these videos made by some Berkeley grad students useful.

View original post

Tyler Williams's avatarCausal Sports Fan

Here’s a fun fact. NHL first round winners were 45-54 in shootouts in the regular season. First round losers were 63-43.  Here are the match ups (higher regular season point total first, shootout record in parentheses, winner in bold):

  • Rangers (4-5)  vs. Ottawa (6-4)
  • Bruins (9-3) vs. Capitals (4-4)
  • Devils (12-4) vs. Panthers (6-11)
  • Penguins (9-3) vs. Flyers (4-7)
  • Canucks (8-7) vs. Kings (6-9)
  • Blues (4-10) vs. Sharks (9-5)
  • Blackhawks (7-7) vs. Coyotes (6-10)
  • Predators (5-5) vs. Red Wings (9-3)

So, the team with the lower shootout win percentage won seven out of eight series. The team with the higher point total only won four out of eight (Rangers, Blues, and Predators), in part because good shootout records inflated some teams’ point totals. Why do we still have shootouts again?

View original post

drunksandlampposts's avatarDrunks&Lampposts

A recent post on the Junkcharts blog looked at US weather dataand the importance of explaining scales (which in this case went up to 118). Ultimately, it turns out that 118 is the rank of the data compared to the previous 117 years of data (in ascending order, so that 118 is the highest). At the end of the post,

I always like to explore doing away with the unofficial rule that says spatial data must be plotted on maps. Conceptually I’d like to see the following heatmap, where a concentration of red cells at the top of the chart would indicate extraordinarily hot temperatures across the states. I couldn’t make this chart because the NOAA website has this insane interface where I can only grab the rank for one state for one year one at a time. But you get the gist of the concept.

In this spirit…

View original post 87 more words

This planet obeys the law—stats on volcanic eruptions show pattern called Benford’s Law

This planet obeys the law—stats on volcanic eruptions show pattern called Benford’s Law

The Age of Sail Visualized

The Age of Sail Visualized

Cheers.

Tyler Williams's avatarCausal Sports Fan

Earlier this week, I linked to an interesting auction-based proposal to help improve fairness in NFL overtime games. Right now, the coin flip gives the winning team a boost more often than not (the only exception is if the winning team mistakenly takes the ball but has a VERY weak offense relative to its defense, or, likewise, if the losing team has a VERY strong defense, relative to its offense).

The idea of the auction is to give each team “accurate” odds of winning by having them bid for the ball, using starting field position as currency. As you bid to start deeper and deeper in your own end, the odds of you scoring before your opponent drop. At some starting field position for each team (maybe around the 17 yard line), the odds should be close to fair

View original post 324 more words

Tyler Williams's avatarCausal Sports Fan

There’s a new paper out this month by Casey Ichniowski and Anne Preston concerning the NCAA tournament and the NBA draft (thanks to my PhD buddies Chris and Felipe for passing it along). Their argument is that unexpectedly strong tournament performance (especially team performance) causes players to be selected earlier in the NBA draft. This isn’t a bad thing though — in fact, they suggest that these strong tournament players tend to outperform their draft position in the NBA.

I believe their results saying that tournament performance affects draft position (this has also been shown by Chaz Thomas in an undergraduate thesis, and by David Berri, Stacey Brook, and Aju Fenn), and I mostly believe their results that strong tourney performers should be drafted even earlier, though their set up is a little odd for this second issue.

The clearest way to show that teams make mistakes in the…

View original post 420 more words