haotu : an open lab notebook


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)

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



R histogram on scatterplot

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



## 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
yh <- hist(y, breaks = k, plot = FALSE)
barplot(-(yh$intensities),space=0,horiz=T, axes = FALSE)

breaks <- 10
xh <- hist(x, breaks = k, plot = FALSE)
barplot(-(xh$intensities),space=0,horiz=F, axes = FALSE)
## reset the graphics display to default



edited from


R read R code

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



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.




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.