R 培训之 Table
res = read.table("ttest_expression.tsv",sep=",",header = TRUE)
rownames(res)=res[,colnames(res)[1]]
res[rownames(res),colnames(res)[2:length(colnames(res))]]
res = read.table(exp_file, header=T, quote="",row.names=1, sep='\t',check.names=F,as.is=TRUE, encoding="utf-8")
rest = t(res)
ncols(res) nrows(res)
dim(rest) dimnames(rest) rownames(rest) colnames(rest)
typeof class
同种数据类型: Array 数组 Matrix 二维数组
不同种数据类型 :List 列表 data.frame 数据框 (命名元素)
v <- 1:20; w<-sapply(v,function(i){i^2})
>xxx<-matrix(1:20,ncol=4)
>apply(xxx,1,mean)
[1] 8.5 9.5 10.5 11.5 12.5
>apply(xxx,2,mean)
[1] 3 8 13 18
m <- factor(c("red","blue","green","green"))
l <- levels(m)