Displaying 1 result from an estimated 1 matches for "splidata".
Did you mean:
splitdata
2008 Oct 02
0
[solutions] "tapply versus by" in function with more than 1 arguments
...ows
nr = 10
# Data set
dataf = as.data.frame(matrix(c(rnorm(nr),rnorm(nr)*2,runif(nr),sort(c(1,1,2,2,3,3,sample(1:3,nr-6,replace=TRUE)))),ncol=4))
names(dataf)[4] = "class"
#-----------------------------------------------------
#Solution 1:
#works, but need space to allocate the new data: splidata
# Splitting your data
splitdata = split(dataf,dataf$class)
# Correlations
correl=lapply(splitdata,function(x) cor.test(x[,1],x[,2])$estimate)
res=do.call(c,correl)
names(res)=paste('class',unique(dataf[,4]),sep="")
res
#-----------------------------------------------------
#Sol...