我正在遍历矩阵进行一些计算,因此需要一个lapply代码来提高性能。
for(i in 2:nrow(TransposeDataSet)){
for(j in 1:ncol(TransposeDataSet)){
if(TransposeDataSet[[i,j]]!=" 0"){
df <- cbind(rownames(TransposeDataSet)[i], TransposeDataSet[[1,j]])
write.table(df, file = filename, sep = ",", append = TRUE, row.names = FALSE, col.names = FALSE)
}
}
}