Publications by Jim

Obama approval

12.07.2009

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...

1190 sym 2 img

Some detail on the last plot

13.07.2009

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” makes them, well, gray.cex.lab=1.25 and cex.axis=0.75 make the axis labels 1.25 times larger...

2114 sym 4 img

A recommended book

13.07.2009

I’ve been getting a lot of help from this book:While written for S-Plus, nearly everything in it is applicable with R. Related To leave a comment for the author, please follow the link and comment on their blog: Learning R. R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other top...

525 sym 2 img

Job grade plot

15.07.2009

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 Congressional 100 day job grades”)abline (or,lwd=2,col=”...

1230 sym 2 img

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

15.07.2009

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: Estimate Std. Error z value Pr(>|z|) (Intercept) -5.96130 1.40609 -4.240 2.24e-05 ***b 0.10950 0.024...

1620 sym

Adding a legend to a plot

20.07.2009

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=”blue”,lwd=2.5) # adds a line for health expenditures legend(20...

965 sym 2 img

Learning R 2009-08-28 13:11:00

28.08.2009

fydeficit.1projectedpng(“c:/data/deficit_color.png”,height=480,width=480)plot(deficit.1~fy,ylim=c(-12,5),type=”n”,lwd=2,col=”red”,main=”Federal budget deficit, 1990-2019″,cex.lab=1.1,cex.axis=.75,xlab=”Fiscal year”,ylab=”Deficit (% of GDP)”)rect(1988,-15,1994,6,col=”#FF9999″,border=NA)rect(1994,-15,2002,6,col=”#6699F...

1058 sym 2 img

Public opinion on health care reform

12.10.2009

hc_appattach(hc_app) hc_fit.o1hc_fit.f1hc_fit.o2hc_fit.f2plot(as.Date(Dates),Oppose,main=”Public opinion and health care reform”,ylim=c(0,80),pch=16,xlim=c(as.Date(“2009-01-01”),as.Date(“2009-11-01”)),cex.axis=.85, col=”#E6ADD8″,xlab=””,ylab=”Percentage approving or opposing”) points(as.Date(Dates),Favor,pch=16,col=”...

911 sym 2 img

Introduce your friends to R

12.02.2010

http://blog.revolution-computing.com/2010/01/introduce-your-friends-to-r.htmlhttp://www.typepad.com/services/trackback/6a010534b1db25970b0120a7ed6fd2970b Related To leave a comment for the author, please follow the link and comment on their blog: Learning R. R-bloggers.com offers daily e-mail updates about R news and tutorials abo...

558 sym

ggplot2 (qplot) text size

22.02.2010

I’m trying to learn qplot in ggplot2, and I’m having a difficult time adjusting text sizes. Well, difficult doesn’t descibe it – I can’t do it at all. The manual tells me I can use cex just like in plot, but it’s not working… Related To leave a comment for the author, please follow the link and comment on their blog: ...

632 sym