.libPaths(); #add new path
getwd(); #get the directory of working space
setwd('/home/mingyang/R/data'); #set the directory of working space
data = read.table(file='data.txt',header=TRUE); #loading the data set
edit(data); #viewing the data set
dim(data); #get the dimension of data set
names(data); #view the names of variable
nrow(data)
#correlation analysis
#pairwise mode
for (i in 1:(ncol(data)-1)){
for (j in (i+1):ncol(data)){
lab = paste('the correlation analysis
between ',names(data)[i],' and ',names(data)[j]);
print(lab);
re = cor.test(data[,i],data[,j]);
print(re);
}
}
#partial correlation analysis
#pairwise mode
library(ppcor); #load the library of ppcor
getwd(); #get the directory of working space
setwd('/home/mingyang/R/data'); #set the directory of working space
data = read.table(file='data.txt',header=TRUE); #loading the data set
edit(data);
dim(data);
names(data);
nrow(data)
#correlation analysis
#pairwise mode
for (i in 1:(ncol(data)-1)){
}
#partial correlation analysis
#pairwise mode
library(ppcor);
