Going Deep with David Rees

Today on the blog: a TV show recommendation. Season 2 of Going Deep with David Rees started last week and I think it’s a really good show. The basic idea of each episode is that David is trying to figure out how to do something. Something simple, like how to make an ice cube, because it turns out that even simple things are actually really complex and interesting when you break them down. While that premise is immediately interesting to me, one of the things I like best about the show is its warm sense of humor and an open and sincere quest for knowledge of everyday life. It’s this same sense of wonder and propensity for questioning things around me that initially made me want to be a scientist (and now, study how people learn science).

David Rees is a well-known artisanal pencil sharpener. Ok, maybe not well-known to a large number of people, but still, if you send him a pencil he will sharpen it by hand for you. He wrote a book on How To Sharpen Pencils, so he probably knows what he’s talking about. He is probably actually more well-known for being the person responsible for the political cartoon Get Your War On which, at least for me, made the post-9/11 George W Bush years slightly more bearable.

Season 1 of GDDR focused on important questions like How to Open a Door, How to Flip a Coin, How to Shake Hands, and How to Dig a Hole. Those might sound like silly topics for a show, and they are to a certain extent, but that’s not really what episode is totally about.

Sadly, season 1 is not available to stream anywhere at the moment, but it’s not too late to get on the bandwagon for season 2. The first episode was about How to Pet a Dog and tonight’s second episode was about How to Eavesdrop. Tonight’s episode was a really good example of how they can take a simple question and expand it into a really interesting and engaging sciencey show.

How to Eavesdrop is not really about eavesdropping perse. It is about sound. Which is one of my favorite physics topics. As David says in the episode, “how do sound waves get turned into something my brain recognizes as sound?”. Even though he talks to a former CIA spy about actual eavesdropping, the heart of the episode (to me, at least) is talking to the audiologist and learning how the ear works and talking to the cognitive scientist about how we interpret sound waves to understand speech. They even talked about the McGurk illusion which is fascinating and is also something I wrote about on this very blog about four years ago. And, to make my little academic heart even happier, GDDR popped up a citation to the McGurk et al. paper when they talked about it!

If you’re looking for a fun and engaging bit of science on your TV (or computer), you should definitely check this show out.

Beethoven visualization

I came upon this amazing visualization of Beethoven’s 7th Symphony a little while ago. I found it when searching for this piece1 (one of my favorite classical music pieces) and realized it was also a super cool visualization.

Each color corresponds to one type of instrument, from the orange violins to the greenish flutes, the yellow trumpets, and the blue bassoons. I really like how it shows the complexity of the music and also allows you to see patterns in the piece as they develop over time and repeat.

  1. I was trying to remember if this was the music that was in Mr. Holland’s Opus when he was talking about Beethoven not being born deaf. It was

R Basics

This is the second part in an ongoing series I’m doing about why I think R is awesome and why you should be using it. (Check out part one!)

So now that you have downloaded and installed RStudio and have some data you want to play with, what are the next steps? How do you get started really working with your data? In this post I’ll cover an overview of the basics of working with R. Future posts will have more details on some of these topics.

Project spaces and working directories

So RStudio has you create a “project” when you get started. You tell it where you want the project to be and then it creates a file with “.Rproj” at the end. The location where this project resides is also your working directory. This will be relevant when trying to load in data

You can have more than one project (in different places if you want) and I have found creating multiple projects is mostly helpful for keeping different R projects separate. For instance, I have a main R project called “R Stuff” and then also separate projects for a couple of the bigger research projects that I work on. Things not attached to one of those two bigger research projects go in R Stuff and then I sort them out later and move them if they grow into their own thing.

My suggestion is to create most of your code/scripts/whatever in an R script file (extension .R) instead of just using the console to type in commands when you need them. You can load one of these in the main RStudio panel and type and edit your code here. Once you have some code/commands you like, you don’t need to copy them down into the console, you can just hit command-return (on a Mac, probably control-return on Windows) (or use the “Run” command in the upper right corner of that main window.

This script will allow you to do a couple of things: first, you can see your whole data manipulation/analysis/graphing workflow all at once; second, you can make changes to one step (e.g., switching the size of your graphed data points) and then re-run the code easily; third, you can write comments.

Now, I am not always the best at writing comments. But I try. And it’s really important. Even if you don’t think anyone else is ever going to see your code, you might need to look at it later. And no matter how smart and clever you think you are (well, actually I think if you’re super cleve then this is going to be more important because on a future day you may not be having a super clever day), you will probably need to read your code again. You are always, at a minimum, collaborating with yourself. And you deserver to have well-commented and documented code. So do yourself a favor and write some sensible comments.

Loading and viewing your data

Ok, so you have a data file and you want to start working with it. You have a few options. Most likely, it’s a .csv file and I’m going to assume to start that it’s in your working directory so you can use the command

d1 <- read.csv("MyDataFile.csv")

This will create a new dataset called d1 that is made up of what was in your csv file. You can use the “Import Dataset” button in the Environment panel. If your data file is in another location, you will have to enter the correct file path.

For the rest of the examples here, I’m going to use one of the sample data sets that comes with some R packages. The mpg dataset is one of the typical datasets for examples, as it comes in the base package. It is a datatset of car models and gas mileage data. Play along at home with the following commands.

To start, load the dataset: data(mpg). This should create an entry in the Data section of the Environment panel on the right. It should tell you the name of the dataframe and that there are 234 observations of 11 variables. Alright, but if we want to look at the data? If you type head(mpg) the console will output the header of the dataframe: the column names and the first six rows of data.

I prefer using glimpse(mpg) which is actually a command from the dplyr package. (If you haven’t already downloaded the dplyr package, now is a good time. We will be using it a lot in later posts.) Glimpse gives you a more compact view of more of the dataset and also tells you how R is interpreting each variable. For instance, R thinks that manufacturer is a factor (true) and that year is an integer (also true). displ is a “double integer” which is a bit weird, but for now, let’s just go with that it’s a special class of numerical variable. None of the text-based variables showed up as strings, which is good for our purposes with this dataset.

This is fine if you have a relatively small dataset, but it begins to get unwieldy if you have a lot of variables. The summary(mpg) call will give you a different view of your data. For the text-based variables, it gives you a count of them (up to a point) and for the numerical variables, it spits out the minimum, quartiles, mean, and maximum values. Pretty handy for a quick check.

If you want to see the whole dataset (or at least, a lot more of it, depending on how big it is) in a format more closely resembling that which you’re used to in Excel or something, you can use View(mpg). This will pop up a “normal” looking dataset in the main window for you to peruse.

Alright, now that we have looked at our data, let’s talk about variables. To access a specific variable, you will use the dollar sign. So, if you want to look at (or refer to) the model variable in the dataframe, you will call it by mpg$model. This way R knows that you are looking in the dataframe mpg and you want the variable model. You can use this in combination with lots of other things. For instance, if you wanted to find the minimum year of car that is in the dataset, you could use min(mpg$year) and it should output 1999.

If you make some changes to your dataset (e.g., adding a variable, reshaping it, filtering it, etc. — all topics for a future post), you can also save your dataset in a recognizable format. So if your new dataframe is called mpg2 you can export a csv of that using write.csv(mpg2, file="mpg2"). This will put a new csv file in your working directory with the filename mpg2.csv.

Other things to think about with R

In order to maintain an up-to-date version of R within RStudio, there are three separate things you need to update: RStudio itself (the application), R (the base), and all of your packages.

Updating your packages is easy in RStudio. In the Packages tab in the lower right corner (using the default set-up), there is an “Update” button that will easily show you which packages have updates available and let’s you download and install them. Super easy. (Updating RStudio is easy too: look in the Help menu (at least on Macs).)

When you start up RStudio, the console will give you a readout of the current version of R that you are running. As of today, that is version 3.2.2 (“Fire Safety”), but if you have an earlier version of R — as long as it’s not too old — most things should run fine. Updating R is sometimes a pain because you can’t do it directly in RStudio (which I think is confusing to people because you can update your packages easily in RStudio). When you download a new version of R, RStudio will automatically detect that, so that’s not too bad. However, RStudio tries to be helpful and store your downloaded packages in the correct place, but a major version update to R actually creates a new location and you have to migrate all of your packages over to that new place. It’s a bit of a hassle, but there is an easy way around it.

update.packages(checkBuilt = T, ask = F, type = "binary")

RStudio also has support for version control. Woo! You can use either git or SVN. I have more experience with SVN, but I am in the midst of switching over to git so maybe I’ll post about that at a later date. I’m not going to go into all of the details for how to set up and use version control, but, I will say that it’s a good idea even if you don’t need it for collaboration or sharing purposes.

Next post: we’ll look at how to organize and manipulate your data using my favorite package dplyr! Check it out here.

Je t’aime Paris

What happened tonight in Paris is just horrible. I don’t even know what else to say about it except it’s awful.

Paris is a beautiful city. I visited there in 2004 and want to go back someday soon.


I have watched Casablanca probably 20 times. It is one of my favorite movies and one of the greatest movies ever made. And the most effecting scence for me, every time, is the part where the Nazis are in the bar and start singing their garbage Nazi song and then slowly the rest of the bar patrons (led by the freedom figher Victor Laszlo) start singing La Marseillaise and eventually drown out the Nazis. It is a very powerful scene and it always always always makes me cry.

The terrorists only win if we are afraid. But we can show them with our voices that together we are stronger than them and we will drown them out.

Disneyland is a TARDIS

Disneyland is a TARDIS. Let me explain.

The TARDIS is Doctor Who’s1 time machine. It is cleverly disguised as a blue police box. TARDIS stands for time and relative dimension in space but that’s just because acronyms are cool and don’t worry about it too much unless you’re asked that question at a trivia competition. The important things about the TARDIS (besides it’s big blue appearance) are twofold: it is a time machine and it is bigger on the inside.

Now while I do think that Disneyland is (or can be at its best) a kind of time machine, transporting someone to the wonder and awe of their childhood, I think the other aspect is more interesting. Disneyland is bigger on the inside.

I was listening to a podcast sometime last year (I wish I could remember which one it was – it was two dudes talking so it could be literally any podcast) and they were talking about some of the architectural design and design constrains of Disneyland. I had heard most of it before (the hub design, using high points in each land for orientation, making sure there was no bleed over between lands, etc.), but the conversation on the podcast then ventured into new territory for me: that some of the rides actually existed outside of the park boundaries (aka beyond the Disneyland Railroad loop). Once I heard this, it was so obvious, but I hadn’t thought about it before. Of course some of the rides went beyond the boundaries. That’s the only place they could go.

I have maintained for some time that Disneyland is superior to the Magic Kingdom in Disney World and one of the main reasons (besides being the original) is design constraints. Design constraints are usually a good thing. They make people more creative. Think about haikus, sonnets, and the 3 minute pop song. Enormous creativity can come out of sometimes harsh or even arbitrary constraints. Disneyland is no exception.

The land that Disneyland sits on in Anaheim is not that big. If you’ve ever run a half-marathon through the park or looked at it on Google maps, you will understand just how small it really is. But when you’re in the park, it doesn’t seem small at all. In the proper context, it is huge and seems to defy normal spatial dimensions. And that’s because it cheats.

Some of the “cheating” is just the normal kind of expected thing. For instance, it is pretty obvious that Pirates of the Caribbean is underground and you can kind of think of that as multiplying available space. But there is something else going on as well – actually extending the park beyond the apparent boundaries.

I have two examples of this. Now, to be clear, this is mostly just speculation on my part

Indiana Jones and the Temple of the Forbidden Eye (or just: the Indiana Jones ride like everyone calls it)

The full line is half a mile long. To put that in perspective, that is basically the same distance as walking from the main entrance plaza (near Great Moments with Mr. Lincoln) to the hub (the Mickey and Walt Disney statue) and back two times. So even if that line is snaking back and forth a lot (which, of course, it is), you are still going quite a distance in that full line and that line is taking you somewhere that is not that close to where you started.

And then the ride itself is quite large. It takes up even more space than the line, probably by a wide margin. And when you try to figure out where exactly that is, well, some of it is going to have to be outside the park boundaries.

Disneyland Google Maps

When you look at the satellite images of the park, it’s even more obvious. There is the big forrested area that is the Jungle Cruise and then there’s Pirates of the Caribbean which is already underground. So the Indiana Jones ride is pushed further out and has to be on the other side of the railroad. There is literally no other place for it to go.

The Haunted Mansion

The Haunted Mansion might also have a similar situation, but my guess is that it is not as much (i.e., not as far outside the park as the Indiana Jones ride is). Obviously, there is the clever downward elevator switcheroo at the beginning2 (which, as a kid, made me feel really awesome when I figured that out). So that gets you underground and then you have to walk a bit and then get on the conveyor belt ride3.

The Rivers of America is preventing too much underground construction in that direction, so it has to go the other way. And the Haunted Mansion isn’t exactly what I would space efficient. It is another large, winding ride and all of that has to go somewhere. And that somewhere is, at least in part, probably outside the park4.


I think it’s great that Disneyland is able to trick our perception of space so much. (And time, too, for that matter – either waiting in a long line or just spending time with family and friends – most of it seems to fly by.) It’s just another interesting aspect of the happiest place on Earth.


  1. For those of you not familiar with Doctor Who, the longest running sci-fi series on television, you should do yourself a favor and watch some of it. The newer seasons are on Netflix. My favorite Doctor is the Tenth (David Tennant). Something about the suit and Converse combo, maybe. 
  2. with no windows and no doors 
  3. The Haunted Mansion is also another example of some of the problems I see with the Magic Kingdom in Florida. They basically copied the design and structure of Disneyland’s Haunted Mansion over there, but they didn’t have the same design constraints about it needing to be underground to save space. So it, and a lot of other things, feel a bit out of place because there is so much more space in Walt Disney World. They have basically unlimited space there and so the design constraints are different. 
  4. I think this is also why there are more larger rides on the west side of the park. If you look at the map again, the east side of the park goes up against the 5 freeway and my guess is that they can’t build under that. The park is kind of lopsided. 

Auntie Cynthia

Last week I was Super Aunt Cynthia and spent five long days with my brother and sister-in-law and their newborn twins Lucas and Sophia. It was exhausting, but also amazing and I am so glad that I could be there and help out and spend that time with them.

Lucas and Sophia turned four weeks old today. I can’t believe it’s already been a month! Lucas is eating a lot and is trying to catch up with his sister who was a bit ahead of him in terms of weight. Last week, Sophia quickly earned the nickname “angel baby” because she was such a good sleeper and was so calm and relaxed most of the time. Lucas was “fussy butt” because he basically didn’t want to sleep and just wanted to eat eat eat. They both stole my heart though.

Here is our angel baby sleeping, as she loves to do:
angel baby

And here is our fussy butt, awake and being curious:

And here’s Anthony sleeping, because the other major theme of the week was getting naps here and there whenever we could:
the third sleepy kid

However, I think one of my favorite pictures was when Lucas started crying in his arms and Anthony decided to impersonate him:
Anthony impersonating Lucas

And here’s the whole new family:

They are both lovely babies and I can’t wait to see them grow up to be amazing people. I feel very lucky.
bro and sis

Check out the full album of Lucas and Sophia pictures here.

The world will never be the same

So I didn’t write a blog post yesterday. It’s actually been a few days since I’ve posted. I skipped Saturday on purpose because I was at Disneyland with my cousins (more on that later). Sunday I was too tired, so I gave myself a pass. Yesterday (Monday), I should have written something. But I didn’t. I sat at the computer and had time to do it. But I ended up listening to Hamilton for an hour instead of writing a post.

Hamilton is the new Broadway musical sensation that is taking over the world. It tells the story of Alexander Hamilton from his arrival in New York City in 1776 through the Revolutionary War, the building of the U.S.A., up to his untimely death in 1804. The musical was written by Lin-Manuel Miranda (who also just recently received a MacArthur genius award) and is based on the biography by Ron Chernow.

I had first heard about the show a couple years ago. I have always loved musicals and so I kind of follow the news w/r/t new musicals. Lin-Manuel Miranda worked on the show for more than six years before it came to Broadway and early on in 2009, he performed a version of the opening number at a poetry and spoken word performance at the White House. After that, a lot of people were anxious to see what, if anything, would come of an ambitious, rap/R&B inspired musical about a forgotten historical figure.

And last year, the show opened off Broadway to frankly insane reviews and I didn’t think there was any possible way it could live up to all of the hype I was hearing.

In September, NPR was streaming the full original cast album as part of their First Listen series. I listened to the whole thing immediately and was blown away. The hype was real. It is legit.

I like NPR’s description of the show:

The songs he wrote for Hamilton are not rap songs. This is musical theater made by someone who knows rap to be all our cultural lingua franca, whose sense of humor is legible to people like us. It is songwriting done within rap’s regulations and limitations. It’s a work of historical fiction that honors the sentiments of rap, a play off collective memory that feels overwhelming personal.

Like all good musicals, it has highs and lows, powerful songs and sad songs and love songs and an interesting and engaging cast of characters. Also, it’s so funny! The fact that this musical is also (mostly) historically accurate makes it all the more amazing that it succeeds in such a powerful way as a musical in its own right, not just because it handles the subject matter so well. It is a tragic story, but the musical breathes so much life and relevance into the life and legacy of a man that lived more than two hundred years ago, that it almost feels more triumphant than tragic at the end.

I’ve been listening to it pretty much non-stop for the last month. I’ve been trying really hard not to sing random songs during meetings and on the train and I’ve mostly succeeded. It is so good and I just want everyone to know about it and share in the joy that it is bringing me and thousands of others who are listening to it (or are lucky enough to get tickets). Every week I have new favorite songs. Last week it was “Dear Theodosia” and “The Schuyler Sisters” and this week it’s mostly “Helpless” and “The Election of 1800”. Also, the three King George songs will pretty much always be hilarious and amazing.

Most of my knowledge about Alexander Hamilton is from high school AP U.S. History and it comes down to two main bullet points: he was the first secretary of the treasury (and let’s be honest, this is easier to remember because he’s on the $10 bill) and he helped write the Federalist Papers. Since I do a lot of trivia competitions, this is probably more knowledge about Alexander Hamilton than most people remember more than a decade after high school. So Hamilton also excels at bringing light to one of the lesser known and remembered Founding Fathers. He had an extremely important role in the fight for and development of our young country and history should not forget him. It’s wonderful that we have Lin-Manual Miranda and the wonderful cast of Hamilton to continue to tell his story in a very compelling way.

Visualizing without seeing

Last January was the annual Awesome Games Done Quick marathon, where speed runners1 show off and explain their skills while raising money for cancer research. One of the final events of the marathon was a blindfolded speed run of the beginning of The Legend of Zelda: Ocarina of Time (OoT) (basically, the first three dungeons). Yes, you read that correctly: a speed runner Runnerguy2489 was blindfolded and then played OoT.
Continue reading “Visualizing without seeing”

Intro to R

This is the first in a series of posts on the statistics language R.

Do you work with data (doing data processing, analysis, or visualization)? Are you currently using SPSS, Excel, or SAS and you know it sucks but aren’t sure you want to try something new? Have you heard about R and are scared to try it? Have you tried R but are super confused? Do you currently use R but want to know more? If you answered “yes” to any or all of those questions, then this post (and/or one of the following in the series) is for you! R is a free and open source alternative to SPSS, SAS, and other analysis and statistics programs.
Continue reading “Intro to R”

Old Educational Computer Games

I’m hanging out with my brother (and sister-in-law and their newborn twins) this week and in some of our downtime my brother Anthony and I were reminiscing about some of the old computer games we played as kids. We had a Macintosh SE as our first family computer in the late 1980s. There were a bunch of educational games that we played and some non-educational as well.

We both remembered playing Where in the World is Carmen Sandiego1, Dark Castle, Crystal Quest, Tetris (of course), Shuffle Puck, and a few others. But there were two games that we couldn’t quite remember the titles or full descriptions of. Anthony remembered a race car game that had something to do with math and I remembered a quiz/trivia type of game that had something to do with castles. Anthony thought that maybe there was a trophy room in the trivia game where you would be able to over time fill up the room with awards in the game and that sounded right to me as well.
Continue reading “Old Educational Computer Games”