Monthly Archives: February 2008

Find type of variables in a data frame

February 20, 2008
By

sapply(a,class) gives type of field (character, numeric, or factor) for each variable in the data frame a.

Read more »

A wraper function to convert coda files into a BUGS object

February 11, 2008
By

I used to fit Bayesian model using WinBUGS via R a lot. But now I am more and more prone to run models on OpenBUGS directly. I have document the reason why I like OpenBUGS and wrote a auto OpenBUGS function here. In short, I like to be able to know wha...

Read more »

A wraper function to convert coda files into a BUGS object

February 11, 2008
By

I used to fit Bayesian model using WinBUGS via R a lot. But now I am more and more prone to run models on OpenBUGS directly. I have document the reason why I like OpenBUGS and wrote a auto OpenBUGS function here. In short, I like to be able to know wha...

Read more »

R graph with two y-axes

February 4, 2008
By
R graph with two y-axes

I’ve been asked how to do this several times, so I thought it might help to put an example online. x <- 1:5 y1 <- rnorm(5) y2 <- rnorm(5,20) par(mar=c(5,4,4,5)+.1) plot(x,y1,type="l",col="red") par(new=TRUE) plot(x, y2,,type="l",col="blue",xaxt="n",yaxt="n",xlab="",ylab="") axis(4) mtext("y2",side=4,line=3) legend("topleft",col=c("red","blue"),lty=1,legend=c("y1","y2"))

Read more »

R graph with two y-axes

February 4, 2008
By
R graph with two y-axes

I’ve been asked how to do this several times, so I thought it might help to put an example online. x <- 1:5 y1 <- rnorm(5) y2 <- rnorm(5,20) par(mar=c(5,4,4,5)+.1) plot(x,y1,type="l",col="red") par(new=TRUE) plot(x, y2,,t...

Read more »

Drop unused factor levels

February 4, 2008
By

When creating a subset of a dataframe, I often exclude rows based on the level of a factor. However, the "levels" of the factor remain intact. This is the intended behavior of R, but it can cause problems in some cases. I finally discovered how to clean up levels in this post to R-Help. Here is an example:>...

Read more »

Drop unused factor levels

February 4, 2008
By

When creating a subset of a dataframe, I often exclude rows based on the level of a factor. However, the "levels" of the factor remain intact. This is the intended behavior of R, but it can cause problems in some cases. I finally discovered how to clean up levels in this post to R-Help. Here is an example: >...

Read more »

R package: codetools

February 4, 2008
By

Since the release of R_2.6.0, R package developers were advised to use the ``codetools" package to check potential bugs. However, as I am not familiar with computer language, I found the warning messages a bit confusing. For example:> checkUsage(glm.fit): no visible binding for global variable ‘n’I don't understand what it really means. Apparently, `n' was not globally defined but...

Read more »

Paper on the Gillespie Stochastic Simulation Algorithm in press

February 1, 2008
By
Paper on the Gillespie Stochastic Simulation Algorithm in press

Just got news that my revisions to the reviewer’s comments on my paper GillespieSSA: Implementing the Gillespie Stochastic Simulation Algorithm in R were accepted. Hence, this paper is not officially in press in the Journal of Statistical Software. Here’s the … Continue reading →

Read more »