wine <- read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data", sep=",")
# function for test correlatin with p.valuer
correlation.test <- function(data){
ncol <-
length(data)
var.x <- matrix(rep(c(1:ncol),each=ncol), ncol=ncol)
var.y <- matrix(rep(c(1:ncol),ncol), ncol=ncol)
estimate <- data.frame(NA)
p.value <- data.frame(NA)
for(i in 1:ncol){
for(j in 1:ncol){
estimate[i,j] <- cor.test(data[,var.x[i,j]], data[,var.y[i,j]])$estimate
p.value[i,j] <- cor.test(data[,var.x[i,j]], data[,var.y[i,j]])$p.value
}
}
names(estimate) <- names(data)
rownames(estimate) <- names(data)
names(p.value) <- names(data)
rownames(p.value) <- names(data)
return(cor=list(estimate=estimate, p.value=p.value))
}
--------------------------------------------------------------------
Att