haotu : an open lab notebook

2012/09/28

R abline control length

Filed under: R, R graphics — S @ 00:12

It is nice to plot regression lines that are not infinite like what abline gives, a line that spans the range of the data.


fline <- function(object) {
# ``fline'' <--> fitted line.
r <- range(object$model[,2])
d <- data.frame(r)
names(d) <- attr(object$terms,"term.labels")
y <- predict(object,d)
lines(r,y)
}

From here: https://stat.ethz.ch/pipermail/r-help/2008-June/165288.html

2012/09/27

R histogram on scatterplot

Filed under: Uncategorized — Tags: — S @ 03:02

x<-rnorm(100)
y<-x+rnorm(100)

scatter.hist<-function(x,y,pch=21)
{

## start by saving the original graphical parameters
def.par <- par(no.readonly = TRUE)
## then change the margins around each plot to 1
par("mar" = c(1,1,1,1))
## then set the layout of the graphic
layout(matrix(c(2,1,1,2,1,1,4,3,3), 3, 3, byrow = TRUE))

maxx <- x[which.max(x)]
maxy <- y[which.max(y)]
minx <- x[which.min(x)]
miny <- y[which.min(y)]

plot(x, y, xlab = "", ylab = "", pch = pch, bty = "n",
xlim = c(minx, maxx), ylim = c(miny,maxy))

breaks <- 10
k<-c(seq(from=range(y)[1],to=range(y)[2],maxy/breaks),maxy)
yh <- hist(y, breaks = k, plot = FALSE)
barplot(-(yh$intensities),space=0,horiz=T, axes = FALSE)
axis(1,at=seq(min(-yh$intensities),max(-yh$intensities),.1),labels=sort(seq(min(yh$intensities),max(yh$intensities),.1),decreasing=TRUE))

breaks <- 10
k<-c(seq(from=range(x)[1],to=range(x)[2],maxx/breaks),maxx)
xh <- hist(x, breaks = k, plot = FALSE)
barplot(-(xh$intensities),space=0,horiz=F, axes = FALSE)
axis(2,at=seq(min(-xh$intensities),max(-xh$intensities),.1),labels=sort(seq(min(xh$intensities),max(xh$intensities),.1),decreasing=TRUE))
## reset the graphics display to default
par(def.par)

}

scatter.hist(x,y)

edited from
http://www.r-bloggers.com/quick-scatterplot-with-associated-histograms/

2012/09/21

R read R code

Filed under: Uncategorized — Tags: — S @ 02:20

source(“”)
http://stat.ethz.ch/R-manual/R-patched/library/base/html/source.html

2012/09/19

edit windows shortcut keys

Filed under: Uncategorized — S @ 06:30

I want to makes google desktop not the default search engine of my harddrive. win-F brings up google desktop.

http://www.autohotkey.com/docs/Tutorial.htm#Create

http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-do-i-change-the-windows-7-keyboard-shortcuts/0110d32d-66c0-4ce7-8682-eeb896e80c3f

2012/09/09

Share Internet Connection Option Missing Cannot Share Internet Computer to Computer Network

Filed under: Uncategorized — S @ 09:30

Every now and then when I create an ad hoc wireless computer to computer network, the share internet option button is not displayed. There is a great post on http://smallittips.blogspot.nl/2011/06/turn-on-internet-connection-sharing.html

It is reproduced below:

 

“Turn on Internet connection sharing” option missing

Generally, the first time you share your internet on an ad-hoc connection, everything goes fine. But after that, the “internet connection sharing” option disappears. Impossible to find it. Impossible to share your internet connection again… it is linked to the first ad hoc network you have created and won’t be available unless you remove your first-in-your-life-created ad hoc network. The problem is quite tricky as this ad-hoc network is not shown anywhere and restarting your PC will not help.

Here is my solution:
1) Go to your network settings: “Control Panel” / “Network and Sharing Center” and click on “Change adapter settings” (should be called “Manage your internet connections” in my opinion)

2) You should see 2 important connections here:
– your local connection (the one that enables you to connect to the internet). It is probably in state “Network, Shared”.
– your wireless connection (the one you will be using to give internet access to your other devices)
You may have other connections but they are not important here. You will NOT have ad hoc connections

3) Right click on your local connection and go to Properties. There should be a tab called “Sharing” which is activated. Disable it (uncheck the first option “Allow other…”).

4) Disable your wireless connection.

5) Re-enable your wireless connection. As you have unchecked the sharing, when your wireless connection is re-enabled it should not use the internet-sharing-unique-slot

6) Re-create an ad-hoc connection. The option “Turn on Internet connection sharing” should now appear correctly.

If this is not the case, double check that:
– you have re-enabled your wireless connection and that your wireless connection is up (wifi button red, …)
– you have followed the steps properly. Particularly the order of the steps is important

Blog at WordPress.com.