嗨,我有以下 R 脚本
emboss<-read.table("emboss_002.ss",header=T)
x<-table(emboss[,2],emboss[,3])/NROW(emboss[,3])
y<-as.vector(t(x))
nms <- expand.grid(colnames(x), rownames(x))
names(y) <- paste( nms[,2],nms[,1],sep="")
write.table(t(y), file = "nontpsec.csv",append=TRUE)
我有超过 300 个名为 emboss_[i].ss 的文件
如何遍历文件夹以在每个文件上运行此脚本?每个输出都进入同一个 .csv 文件。
顺便说一句 - 这是我的数据框 (x)
x
C E H
A 0.057971014 0.017391304 0.026086957
C 0.005797101 0.002898551 0.002898551
D 0.046376812 0.000000000 0.002898551
E 0.063768116 0.002898551 0.020289855
F 0.011594203 0.005797101 0.005797101
G 0.069565217 0.002898551 0.002898551
H 0.028985507 0.000000000 0.000000000
I 0.017391304 0.008695652 0.002898551
K 0.014492754 0.002898551 0.002898551
L 0.043478261 0.011594203 0.034782609
M 0.005797101 0.002898551 0.002898551
N 0.017391304 0.000000000 0.005797101
P 0.055072464 0.000000000 0.000000000
Q 0.046376812 0.002898551 0.008695652
R 0.049275362 0.011594203 0.023188406
S 0.043478261 0.005797101 0.002898551
T 0.034782609 0.017391304 0.014492754
V 0.037681159 0.014492754 0.008695652
W 0.014492754 0.008695652 0.002898551
Y 0.026086957 0.008695652 0.011594203
非常感谢!