The new sample size calculator for R (already)

aka “Maybe I shouldn’t post so quickly

Just hours ago, I posted my first set of functions for R to determine the sample size for a known population. Then, I had to update that post to reflect my newfound knowledge, and now, I thought I would update again, so that the best functions I came up with would all be in one place.

There are two functions, sample.size.table() and sample.size() which you can easily load in R by typing source("http://news.mrdwab.com/samplesize") at the command prompt.

Here’s some more information about each.

Read More »

Posted in (all categories), Geekiness, Useless Knowledge | Tagged , , , , , | 7 Comments

A sample size calculator function for R

IMPORTANT: This is here mostly to remind me of how I solved my problem. You should read The new sample size calculator for R (already) if you really want to use this function.

In the research class at the Tata-Dhan Academy, students are currently getting into sampling, so I thought I would introduce them to R. However, try as I might, I couldn’t find how to do a simple sample size calculation in R if I knew, for instance, the size of the population I wanted to sample from, the confidence level desired, and the confidence interval desired.

Now, I know that there are literally hundreds of such calculators online, but I thought it would be a good excuse for me to learn how to write a function. Here are my first three four functions which demonstrate some of the features available for writing functions in R. These are relatively basic, and there might be better ways to do this (if there are, please share!) but it was still a fun experiment for me.

Read More »

Posted in (all categories), Geekiness, Useless Knowledge | Tagged , , , , | 2 Comments

Using the reshape package in R for pivot-table-like functionality

A little more than a week ago, I wrote about creating pivot tables in Microsoft Excel and OpenOffice.org. I also mentioned that I would explain how to do similar calculations by using R. This post will explain how to achieve similar results in R by using the reshape package.

I had initially started experimenting with the reshape package several months ago when I was trying to figure out how to reshape data from wide to long formats. However, once I started experimenting with it, I realized I had misunderstood what the reshape package was designed to do. Now that I finally have a grasp of what can be done using the package, I thought I would share what I’ve found using a few examples.

Read More »

Posted in (all categories), Geekiness, Useless Knowledge | Tagged , , , , , , , , , , , | 8 Comments

Sometimes, I wish I could turn my editing eyes off

… but if I did, then I would probably miss out on some of the fun that Indian English has to offer.

Read More »

Posted in (all categories), Humor, India, Pictures | Tagged , , , , , , , | 1 Comment

Pivot Tables in Excel and OpenOffice.org Calc

One of the features I find useful in Excel is the ability to create “pivot” tables. Essentially pivot tables let you summarize big tables of data in different ways, using different variables to “pivot” your data around (hence the name, I guess). Pivot tables are most easily understood through an example, so here’s one done using Excel 2007, and the sort-of-equivalent “Data-Pilot” in OpenOffice.org Calc (OO.o Calc).

Read More »

Posted in (all categories), Geekiness, OpenOffice.org, Useless Knowledge | Tagged , , , , | Leave a comment

Getting data into R

When you first open R, you’re greeted with a screen similar to the following:

?View Code RSPLUS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
R version 2.10.0 (2009-10-26)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
 
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
 
  Natural language support but running in an English locale
 
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
 
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
 
>

I’ve been trying to encourage my students to use R for some of their work, but in the process, I sort of forgot that for most people, starting up a program and just being greeted with a command prompt might be somewhat intimidating. So after several of my students indicated that they had downloaded and installed R but had no idea what to do next, I thought I would write about some of the very basic ways to get started. I recognize that for some huge datasets, the suggestions here are not the best, but for me, and for most of my students, the datasets that we would be working with are actually quite small.

Read More »

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

The awesomeness that is WordPress and child themes

After a long long long time, I decided to get back into some actual website experimentation. For a while, I was really lazy with my site design and settled on using the Atahualpa theme. This was a great be-lazy theme, but I noticed that while browsing other sites, it often became too obvious which sites were made using the theme and me, always wanting “my own thing” decided that it was time to get my hands at least a little bit dirty again.

Read More »

Posted in (all categories), CSS, Geekiness, Website | Tagged , , , , , | Leave a comment

R is like a giant calculator for grownups

One of the things that is interesting about R is how flexible it is. One of the fun things about it is how interactive it can be. While my examples so far have been a little bit more involved, it can be useful to spend some time just getting acquainted with how R performs basic calculations. In fact, I sometimes like to think of R as a giant calculator for grownups to play with. The following syntax snippets show how you can perform basic calculations with R. This is by no means complete, but it should provide a reasonable introduction to someone just getting started with R. (Experienced R users would find this TOTALLY useless….)

Read More »

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

What some of the other people are doing….

I thought I’d take a break from my ego-centric rambling and share a little bit about what other people are doing….

Amy's in the news...

Amy's in the news...

Amy’s busy creating her own website, hosted at http://www.tnsms.org. No, it’s not about text messages from your Tamil Nadu mobile phone; it’s an abbreviation for “Tamil Nadu Socioeconomic Mobility Survey.” Just putting the site live ended up getting her a brief interview in the Times of India. (click on the picture to get a larger image.)


Read More »

Posted in (all categories), General News | Leave a comment

A little spark for presenting your data

For some reason, I’ve been obsessing over the presentation of data. (Either it is that I’ve just read all of Edward Tufte‘s books, or I’m just being a nerd. But I guess that those two things aren’t exactly exclusive….) Considering my obsession, you could imagine how I felt when one of my students stood up and made a presentation that included the following slides, along with the typical, “As you can see here, the production of rice has been decreasing. And as you can see in this chart, the production of wheat has been decreasing,” for slide after slide after slide.


If for some reason you’re not able to see the embedded slides, you can also view the slides in a new window.

Read More »

Posted in (all categories), Geekiness, OpenOffice.org, Useless Knowledge | Tagged , , , | 2 Comments