haotu : an open lab notebook

2013/07/31

Simple Cholesky decomposition example

Filed under: Math and Stats — S @ 05:02

There is a nice example here

the formula

the matrix

the solution

2013/07/29

chrome.exe still running after close :: chrome.exe is caused by cloud print

Filed under: Chrome, Cloud Print, Google, Windows 7 — S @ 03:22

I have found that even if I do not allow extensions in Chrome to run in the background (i.e., in advanced settings), that an instance of chrome.exe is still running as a process once I exit Chrome.

This instance for me was caused by Google Cloud Print. Once I removed my cloud printers, the instance went away.

2013/07/24

Excel function analogous to R any() :: find multiple cells in an excel with same value

Filed under: Excel, Microsoft Products, R — S @ 04:34

IF(COUNTIF("X",B2:D2)>0,"TRUE","FALSE")

csv file with commas in elements

Filed under: Manipulate Data in R, R — S @ 04:03

read.csv(…, colClasses=”character”)

2013/07/17

How to do a segmented, breakpoint, two-part, N-part regression in R

Filed under: Manipulate Data in R, R, R, R Stats — S @ 04:18

library(segmented)

lm.nat<-lm(y~x)
seg.nat<-segmented.lm(lm.nat,seg.Z=~x,psi=list(x=NA),control=seg.control(stop.if.error=FALSE,n.boot=0,it.max=1000))
plot(x,y)
plot(seg.nat,add=TRUE)

2013/07/15

Extract data from a dataframe/matrix with multiple ids :: subset data in R

Filed under: Manipulate Data in R, R — S @ 00:21

If x is an object with a column id and y is a subset list of those ids, then to extract the data from x do:

x.subset<-x[x$id %in% y,]

to do the opposite use

“%w/o%” <- function(x, y) x[!x %in% y] #– x without y

x.subset<-x[x$id %w/o% y,]

2013/07/09

Angle axis x labels on R plot

Filed under: R, R graphics — S @ 04:13

1. First make a plot without the axis you want using xaxt="n":

plot(yy,xx,xaxt="n",xlab="")

2. Then add the axis without labels

axis(side=1,at=xx,labels=FALSE)

where:
side = 1 (this example is for adding labels to the x axis)

3. Finally add the text:

text(xx,par("usr")[3] - ofst, srt = g, adj = 1,labels=labs,xpd = TRUE)

where:
par("usr")[3] gives you the y coordinate for your x axis
ofst is the offset at which you want to plot the labels away from the x axis (note the minus sign).
srt = g this gives the angle to plot the labels, I like (e.g., g = 45)
labs is a vector of your labels
xpd=TRUE plotting clipped to the figure region, also try xpd=NA

Blog at WordPress.com.