Blog Archives

Resources for Learning Data Manipulation in R, SAS and Microsoft Excel

Resources for Learning Data Manipulation in R, SAS and Microsoft Excel

I had the great pleasure of speaking to the Department of Statistics and Actuarial Science at Simon Fraser University on last Friday to share my career advice with its students and professors.  I emphasized the importance of learning skills in data manipulation during my presentation, and I want to supplement my presentation by posting some

Read more »

The advantages of using count() to get N-way frequency tables as data frames in R

The advantages of using count() to get N-way frequency tables as data frames in R

Introduction I recently introduced how to use the count() function in the “plyr” package in R to produce 1-way frequency tables in R.  Several commenters provided alternative ways of doing so, and they are all appreciated.  Today, I want to extend that tutorial by demonstrating how count() can be used to produce N-way frequency tables

Read more »

How to Get the Frequency Table of a Categorical Variable as a Data Frame in R

How to Get the Frequency Table of a Categorical Variable as a Data Frame in R

Introduction One feature that I like about R is the ability to access and manipulate the outputs of many functions.  For example, you can extract the kernel density estimates from density() and scale them to ensure that the resulting density integrates to 1 over its support set. I recently needed to get a frequency table of

Read more »

Exploratory Data Analysis – All Blog Posts on The Chemical Statistician

Exploratory Data Analysis – All Blog Posts on The Chemical Statistician

This series of posts introduced various methods of exploratory data analysis, providing theoretical backgrounds and practical examples.  Fully commented and readily usable R scripts are available for all topics for you to copy and paste for your own analysis!  Most of these posts involve data visualization and plotting, and I include a lot of detail and

Read more »

Performing Logistic Regression in R and SAS

Performing Logistic Regression in R and SAS

Introduction My statistics education focused a lot on normal linear least-squares regression, and I was even told by a professor in an introductory statistics class that 95% of statistical consulting can be done with knowledge learned up to and including a course in linear regression.  Unfortunately, that advice has turned out to vastly underestimate the

Read more »

Online index of plots and corresponding R scripts

Online index of plots and corresponding R scripts

Dear Readers of The Chemical Statistician, While working in my job at the British Columbia Cancer Agency, I learned about a wonderful new data visualization resource from a colleague who works at the British Columbia Centre for Disease Control.  I want to share this with you, as I think that it will help you immensely in your efforts

Read more »

The Chi-Squared Test of Independence – An Example in Both R and SAS

The Chi-Squared Test of Independence – An Example in Both R and SAS

Introduction The chi-squared test of independence is one of the most basic and common hypothesis tests in the statistical analysis of categorical data.  Given 2 categorical random variables, and , the chi-squared test of independence determines whether or not there exists a statistical dependence between them.  Formally, it is a hypothesis test with the following null and

Read more »

Side-by-Side Box Plots with Patterns From Data Sets Stacked by reshape2 and melt() in R

Side-by-Side Box Plots with Patterns From Data Sets Stacked by reshape2 and melt() in R

Introduction A while ago, one of my co-workers asked me to group box plots by plotting them side-by-side within each group, and he wanted to use patterns rather than colours to distinguish between the box plots within a group; the publication that will display his plots prints in black-and-white only.  I gladly investigated how to

Read more »

Useful Functions in R for Manipulating Text Data

Useful Functions in R for Manipulating Text Data

Introduction In my current job, I study HIV at the genetic and biochemical levels.  Thus, I often work with data involving the sequences of nucleotides or amino acids of various patient samples of HIV, and this type of work involves a lot of manipulating text.  (Strictly speaking, I analyze sequences of nucleotides from DNA that are reverse-transcribed from

Read more »

Rectangular Integration (a.k.a. The Midpoint Rule)

Rectangular Integration (a.k.a. The Midpoint Rule)

Introduction Continuing on the recently born series on numerical integration, this post will introduce rectangular integration.  I will describe the concept behind rectangular integration, show a function in R for how to do it, and use it to check that the distribution actually integrates to 1 over its support set.  This post follows from my

Read more »