Monthly Archives: June 2009

Filtering cases

June 26, 2009
By
Filtering cases

Something that's very important to be able to do in data analysis and visualization is to filter out cases. Let's say you want to do identical analyses of two different groups, or of one group and then a subset of it. R can do this a little differently; instead of merely filtering out cases you can create an object...

Read more »

Filtering cases

June 26, 2009
By
Filtering cases

Something that's very important to be able to do in data analysis and visualization is to filter out cases. Let's say you want to do identical analyses of two different groups, or of one group and then a subset of it. R can do this a little differently; instead of merely filtering out cases you can create an object...

Read more »

Development of tikzDevice is underway

June 26, 2009
By

Development of the R package tikzDevice has been underway for about a month now. This package allows for the output of R graphics as TikZ commands. Charlie Sharpsteen and I have gotten it into an alpha stage. There is no real documentation but there is plenty of comments in the code. We have a R-forge

Read more »

Set the significant digits for each column in a xtable for fancy Sweave output

June 26, 2009
By
Set the significant digits for each column in a xtable for fancy Sweave output

This tip may be useful in the situations when you need to set the number of digits to print for the different columns in a matrix/data.frame to be outputted as a LaTeX table.  For example:#install.packages("xtable") #library(xtable) tmp <- m...

Read more »

A bit about linear models

June 26, 2009
By

Before we delve into slightly more advanced plotting commands I want to talk a little about linear models, specifically, linear regression. In R this is very, very simple. For instance, in our 'states' data frame, we might want to look at median household income as a predictor of state education expenditures. The command lm calculates this for us. We'll...

Read more »

A bit about linear models

June 26, 2009
By

Before we delve into slightly more advanced plotting commands I want to talk a little about linear models, specifically, linear regression. In R this is very, very simple. For instance, in our 'states' data frame, we might want to look at median household income as a predictor of state education expenditures. The command lm calculates this for us. We'll...

Read more »

Reading data, and a graph

June 25, 2009
By
Reading data, and a graph

Using Microsoft Excel I'm collecting aggregate data, by state, of various social, political, and economic indicators. I export them into a tab-delimited file called 'states.txt' (pretty clever, I know.) I've got data on education expenditures, firearm deaths per capita, median household income, etc. I'd like to do some analysis and graphing of these data to see if there are...

Read more »

Reading data, and a graph

June 25, 2009
By
Reading data, and a graph

Using Microsoft Excel I'm collecting aggregate data, by state, of various social, political, and economic indicators. I export them into a tab-delimited file called 'states.txt' (pretty clever, I know.) I've got data on education expenditures, firearm deaths per capita, median household income, etc. I'd like to do some analysis and graphing of these data to see if there are...

Read more »

Delete a List Component in R

June 24, 2009
By

In R, the way to delete a component in a list object is different from matrix and vector objects. For a vector, to delete an element:vec <- c(1, 2, 3)vec <- vecFor a matrix, to delete a row or a column:mat <- matrix(c(1,2,3,4), 2, 2)mat2 <- mat # delete a rowmat3 <- mat # delete a columnFor a list,...

Read more »

Delete a List Component in R

June 24, 2009
By

In R, the way to delete a component in a list object is different from matrix and vector objects. For a vector, to delete an element:vec <- c(1, 2, 3)vec <- vecFor a matrix, to delete a row or a column:mat <- matrix(c(1,2,3,4), 2, 2)mat2 <- mat # delete a rowmat3 <- mat # delete a columnFor a list,...

Read more »