Blog Archives

Let’s Make a Date: Date and Time classes in R

July 11, 2013
By

<p>Loading ...</p>

Read more »

Sample size calculations equivalent to Stata functions

June 25, 2013
By

<p>Loading ...</p>

Read more »

Mastering Matrices

April 7, 2013
By
Mastering Matrices

R has many ways to store information.  Most of the time, our data comes in the form of a dataset, which we bring into R as a data.frame object. However, there are times when we want to use matrices as well. This post will show you how matrices can...

Read more »

Extracting Information From Objects Using Names()

March 17, 2013
By
Extracting Information From Objects Using Names()

One of the big differences between a language like Stata compared to R is the ability in R to handle many different types of objects at once, and combine them together or pull them apart.  I had a post about objects last year, but I thought I'd sh...

Read more »

Normal distribution functions

February 25, 2013
By
Normal distribution functions

Ah, the Central Limit Theorem.  The basis of much of statistical inference and how we get those 95% confidence intervals.  It's just so beautiful!  Lately, I have found myself looking up the normal distribution functions in R.  They...

Read more »

Converting a dataset from wide to long

February 1, 2013
By
Converting a dataset from wide to long

I recently had to convert a dataset that I was working with from a wide format to a long format for my analysis.  I struggled with this a bit, but finally found the right sources and the right package to do it, so I thought I'd share my practical ...

Read more »

Translating Weird R Errors

January 20, 2013
By
Translating Weird R Errors

I love R. I think it's intuitive and clever and overall a great language. But I do get really annoyed sometimes at the completely ridiculous, cryptic error messages it often gives me.  This post will go over some of those seemingly nonsensical err...

Read more »

For loops (and how to avoid them)

January 14, 2013
By
For loops (and how to avoid them)

My experience when starting out in R was trying to clean and recode data using for() loops, usually with a few if() statements in the loop as well, and finding the whole thing complicated and frustrating.In this post, I'll go over how you can avoi...

Read more »

Basics of Histograms

December 22, 2012
By
Basics of Histograms

Histograms are used very often in public health to show the distributions of your independent and dependent variables.  Although the basic command for histograms (hist()) in R is simple, getting your histogram to look exactly like you want takes g...

Read more »

Data types part 4: Logical class

November 30, 2012
By
Data types part 4: Logical class

First, an update:  A commentator has asked me to post my code so that it is easier to practice the examples I show here.  It will take me a little bit of time to get all of my code for past posts well-documented and readable, but I have uploa...

Read more »