haotu : an open lab notebook


Scatterplot variations

Filed under: R — S @ 22:13

The car package can condition the scatterplot matrix on a factor, and optionally include lowess and linear best fit lines, and boxplot, densities, or histograms in the principal diagonal, as well as rug plots in the margins of the cells.

# Scatterplot Matrices from the car Package
scatterplot.matrix(~mpg+disp+drat+wt|cyl, data=mtcars,
main="Three Cylinder Options")

The lattice package provides options to condition the scatterplot matrix on a factor.

# Scatterplot Matrices from the lattice Package
splom(mtcars[c(1,3,5,6)], groups=cyl, data=mtcars,
key=list(title="Three Cylinder Options",
text=list(c("4 Cylinder","6 Cylinder","8 Cylinder"))))

The gclus package provides options to rearrange the variables so that those with higher correlations are closer to the principal diagonal. It can also color code the cells to reflect the size of the correlations.

# Scatterplot Matrices from the glus Package
dta <- mtcars[c(1,3,5,6)] # get data
dta.r <- abs(cor(dta)) # get correlations
dta.col <- dmat.color(dta.r) # get colors
# reorder variables so those with highest correlation
# are closest to the diagonal
dta.o <- order.single(dta.r)
cpairs(dta, dta.o, panel.colors=dta.col, gap=.5,
main="Variables Ordered and Colored by Correlation" )




Brackets Cutoff in Equation Editor

Filed under: Microsoft Products — S @ 00:33

The top of brackets and parentheses can be cutoff in equation editor


Go to Format->Spacing and then adjust the “Fence overhang” parameter to fix this problem.


International Purchasing Power

Filed under: Misc — S @ 21:49





country isocode year PPP
China Version 1 CHN 2007 2.21
China Version 2 CH2 2007 2.42
United States USA 2007 1.00


Installing R Packages Windows 7

Filed under: R — S @ 19:03

Here is how I did it. I am not certain if it is the best or if I actually needed to do all the following steps, but it worked.

1. Make sure that you have the built in Administrator account enabled. Go to Run, type lusrmgr.msc hit enter, go to “users” then “Administrator”, make sure that the “account is disabled” checkbox is not checked. You will have to restart your computer

2. log in on the  Administrator acccount.

3. go to “Control Panel”–>”User Accounts and Family Safety”–> “User Accounts”–>”Change my environmental variables” (on left).

4. Under system variables click “New…”

5. For variable name type R_LIBS then for variable value type the path you want the packages installed to (e.g., C:\Program Files\R\R-2.11.0\library)

6. You may have to do this for User variable for Administrator too…







R Ubuntu Installation Tips

Filed under: R — S @ 18:49


The R program is available in Ubuntu. You can install it by choosing r-base-dev from synaptic. Use the menus System -> Administration -> Synaptic package manager.

The version in Ubuntu will generally be out-of-date rather quickly, so you will want to add the CRAN repository. That will keep you up to date. You can do this using the Ubuntu menus. Open: System -> Administration -> Software sources and choose the Other Softwaretab. Click the Add… button and enter:

deb http://cran.stat.ucla.edu/bin/linux/ubuntu lucid/

The packages on the CRAN repository are digitally signed by the packager to ensure that no one is feeding you a trojan horse. It will make installation smoother if you download and install the corresponding public key. Save the text of the key in a file on your desktop. Then run the Software sources application again and choose the Authentication tab. Click on the Import Key File… button and load in the public key. After that, Ubuntu will not prompt you for confirmation every time you try to install a CRAN package.

To install packages system-wide run (from the bash prompt):

sudo R

then type

install.packages(‘pkgname’, dep = TRUE)


H index

Filed under: Misc — S @ 23:29

H index is a scientific productivity and impact index for scientists.

A scientist has index h if h of [his/her] Np papers have at least h citations each…


for Google Scholar


For Web of Science, search for your name (make sure that is for only web of science and not all databases as is the default for ISI). Then click on citation report on the right-hand side of the screen.

Blog at WordPress.com.