Blog Archives

Adding a legend to a plot

July 20, 2009
By
Adding a legend to a plot

It's pretty easy!plot (c(1968,2010),c(0,10),type="n", # sets the x and y axes scales xlab="Year",ylab="Expenditures/GDP (%)") # adds titles to the axes lines(year,defense,col="red",lwd=2.5) # adds a line for defense expenditures lines(year,health,col="...

Read more »

Missing data, logistic regression, and a predicted values plot (or two)

July 15, 2009
By

miss attach miss result1 summary(result1) Call: glm(formula = a ~ b, family = binomial(logit)) Deviance Residuals: Min 1Q Median 3Q Max -1.8864 -1.2036 0.7397 0.9425 1.4385 Coefficients: ...

Read more »

Missing data, logistic regression, and a predicted values plot (or two)

July 15, 2009
By

miss attach miss result1 summary(result1) Call: glm(formula = a ~ b, family = binomial(logit)) Deviance Residuals: Min 1Q Median 3Q Max -1.8864 -1.2036 0.7397 0.9425 1.4385 Coefficients: ...

Read more »

Job grade plot

July 15, 2009
By
Job grade plot

This plot:was created using the following R code:plot (q9e~q8, type = "n",xlim = c(1,13), ylim = c(1,13),cex.lab=1.25,cex.axis=0.75, col.lab = "#333333", xlab = "Obama job grade",ylab = "Congressional job grade", xaxt ="n", yaxt="n",main="Obama and Co...

Read more »

Job grade plot

July 15, 2009
By
Job grade plot

This plot:was created using the following R code:plot (q9e~q8, type = "n",xlim = c(1,13), ylim = c(1,13),cex.lab=1.25,cex.axis=0.75, col.lab = "#333333", xlab = "Obama job grade",ylab = "Congressional job grade", xaxt ="n", yaxt="n",main="Obama and Co...

Read more »

A recommended book

July 13, 2009
By
A recommended book

I've been getting a lot of help from this book:While written for S-Plus, nearly everything in it is applicable with R.

Read more »

A recommended book

July 13, 2009
By
A recommended book

I've been getting a lot of help from this book:While written for S-Plus, nearly everything in it is applicable with R.

Read more »

Some detail on the last plot

July 13, 2009
By
Some detail on the last plot

First we plot approval (app) against date (daten). We also specify a few other things. ylim=c(40,80) specifies that the y axis extends from 40 to 80. xlim=c(-3,210) might seem odd, but we need extra space on the left. pch=16 plots dots, and col="gray" ...

Read more »

Some detail on the last plot

July 13, 2009
By
Some detail on the last plot

First we plot approval (app) against date (daten). We also specify a few other things. ylim=c(40,80) specifies that the y axis extends from 40 to 80. xlim=c(-3,210) might seem odd, but we need extra space on the left. pch=16 plots dots, and col="gray" ...

Read more »

Obama approval

July 12, 2009
By
Obama approval

Working some more with time series data. Here we have a graph of Obama job approval numbers, with two LOWESS-fit lines added for trending:Figure1. President Obama job approval, Jan 2009 - present.There's actually some pretty fancy stuff going on there, as the following code shows.polls lfit1 lfit2 plot (app~daten, ylim=c(40,80), xlim=c(-3,210),pch=16, col="gray",cex.lab=1.25,cex.axis=0.75,col.lab = "#777777", xlab="",ylab="Obama...

Read more »