Tag Archives: code

Stratified random sampling in R from a data frame

After a little bit more work, there’s a new stratified random sampling function, this one letting you sample from a data frame, returning all the variables for each of your samples as a nice data frame that you can continue working on as usual. Get the function at http://news.mrdwab.com/stratified. Usage notes in the head of [...]

Posted in Geekiness, Useless Knowledge | Also tagged , , , , | 4 Comments

Stratified Random Sampling in R–A Function in Progress

IMPORTANT: This is here mostly to remind me of how I solved my problem. You should read Stratified random sampling in R from a data frame if you really want to use this function. I know that sampling is quite complex, and I will admit that I know very little about its complexities. Fortunately, software [...]

Posted in (all categories), Geekiness, Useless Knowledge | Also tagged , , , , , | Leave a comment

Reshaping data in R revisited

A year ago, I wrote a post about reshaping data from a wide format to a long format. I thought that considering how much time had passed, it would be good to revisit R’s in-built reshape functions. For these examples, I’ve copied the Stata examples from the UCLA Academic Technology Services’s “Reshape data wide to [...]

Posted in Geekiness, Useless Knowledge | Also tagged , , , | Leave a comment

Quickly reshaping data from “wide” to “long” formats in R

A lot of the times, students at the Academy enter data in a “wide” format (since it is a very natural way to enter data in a spreadsheet). Let’s say, for example, that they were collecting data for a household, and for each person, they were collecting information on three variables. Assume also that they [...]

Posted in (all categories), Geekiness, Useless Knowledge | Also tagged , , | 4 Comments

Simple sampling with R

I mentioned in an earlier post (Am I inconsistent?) that I got interested in R because Amy had asked me to help her with some sampling at one point. Since that was my starting point, I thought I would share some of my experiments with you. In this post: Simple random sampling Simple random sampling [...]

Posted in Geekiness, Useless Knowledge | Also tagged , , | 1 Comment