[R] Relative frequency of cases in data frame matching a specified criteria

2009-01-23 Thread Stefan Björk
I want to get the relative frequency of cases in a data frame that matches a specified criteria, omiting NA values. This seem so simple, but I can't come up with an effective way. nrow(data[data$variablevalue !is.na(data$variable),])/nrow(data) works but is very ineffective and CPU consuming

[R] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread Stefan Björk
Hello helpers, This is probably quite simple, but I'm stuck. I want to create a summary statistics table with frequencies and summary statistics for a large number of variables. The problem here is that (1) there are two different classes of categories (sex, type of substance abuse and type of

[R] Algorithm for calculating McCall's T-scores

2008-12-18 Thread Stefan Björk
I'm looking for a function or algorithm for calculating McCall's area transformed T-scores, but have not find any. An algorithm is described on http://www.visualstatistics.net/Visual Statistics Multimedia/normalization.htm, but this seem to be an overly complicated procedure for implementing in R.

Re: [R] Algorithm for calculating McCall's T-scores

2008-12-18 Thread Stefan Björk
I seem to have solved this on my own: t.score.table - data.frame(T=10:90,F=pnorm(10:90,mean=50.5,sd=10)) t.score - function(x) { p - ecdf(x) t - cut(p(x),breaks=c(t.score.table$F,Inf),labels=t.score.table$T) t - as.numeric(levels(t))[as.integer(t)] return(t) } /S 2008/12/18 Stefan Björk