Re: [R] Cutting hierarchical cluster tree at specific height fails

2014-07-15 Thread jlh.membership
Hi Johannes, Looking at the code for cutree(...), if h is provided but not k, then cutree(...) calculates k from h and calls a C function with k to cut the tree (but all this only if height is sorted). So we can short circuit the test this way: cutree.h <- function(tree,h) { # this line adapt

Re: [R] Zeta-squared transformation use R?

2014-07-14 Thread jlh.membership
Yes, absolutely! Sorry about that: zeta.sq <- function(data) { z <- scale(data) zeta.sq <- ifelse(z>0,1+z^2,1/(1+z^2)) } -Original Message- From: Michael Dewey [mailto:i...@aghmed.fsnet.co.uk] Sent: Monday, July 14, 2014 6:57 AM To: jlh.membership; 'Miles Y

Re: [R] Zeta-squared transformation use R?

2014-07-13 Thread jlh.membership
Hi Miles, If I read the paper correctly, zeta-squared is simply: (1+z^2) for z>=0, and 1/(1+z^2) for z<=0, where z is the z-score (Eqn. 11 in the paper). Z-scores can be calculated in R using the scale(...) function. So this should produce a zeta-squared transformation. zeta.sq <- function(dat

[R] ggplot: choropleth map with polygons that have holes

2014-02-25 Thread jlh.membership
I am encountering a problem using *geom_polygon(., fill=.)* with a dataframe created using fortify(map) *if the polygon has holes*. It appears that fill=. ignores the holes - -eg. fills them as if they are not present. geom_path(.) on the other hand does recognize the boundaries of the holes.

Re: [R] Thoughts for faster indexing

2013-11-21 Thread jlh.membership
Not sure this helps but... ## # data frame with 30,000 ID's, each with 5 "dates", plus some random data... df <- data.frame(id=rep(1:3, each=5), date=rep(1:5, each=3), x=rnorm(15), y=rnorm(15, mean=1),z=rnor

Re: [R] Overlay boxplot and scatter.smooth line

2013-11-20 Thread jlh.membership
Same thing using ggplot... # your data x <- c(rep(1,100),rep(2,100),rep(3,100)) y <- c(rnorm(100,1),rnorm(100,2),rnorm(100,3)) df <- data.frame(x=x, y=y) library(ggplot2) ggp <- ggplot(df) + labs(x="X", y="Y") ggp <- ggp + geom_boxplot(aes(x=factor(x), y=y)) ggp <- ggp + geom_smooth(formula=y~

Re: [R] R for a stats intro for undergrads in the US?

2013-11-17 Thread jlh.membership
Googling "R for psychology students" I found this: http://health.adelaide.edu.au/psychology/ccs/docs/lsr/lsr-0.3.pdf and this: https://personality-project.org/r/ The latter has links to many short courses and tutorials. If you do end up using R, I find the following sites extremely helpful: Qui

Re: [R] Calculate Range

2013-11-17 Thread jlh.membership
An approach using data tables: ### library(data.table) # dt: some data arranged by group dt <- data.table(group=c(rep("a",5), rep("b",10), rep("c",15)), values=1:30) # summarize by group smry <- dt[,list(min=min(values), max=max(values), range=diff(range(values))), by="group"] smry ### -Ori

Re: [R] Bug in predict.lm?

2013-11-16 Thread jlh.membership
This definitely looks like a bug and should really be reported. Denes' diagnosis is right on. I get the bug here: > z <- lm(rnorm(10)~I(1:10)) > > predict(z, int="conf", scale=1) Error in predict.lm(z, int = "conf", scale = 1) : object 'w' not found And also here: > z <- lm(rnorm(10)~I(1:10))