Multiple Files For Reading,Heatmap And Saving
1
0
Entering edit mode
11.4 years ago
robjohn7000 ▴ 110

I have multiple files to read and also do heatmap after which the outputs will be saved. Somehow, there is a problem(s) with my code below and I can't figure out why it is not working. Files: mxn.dat, scu.dat, emun.dat, ser.dat

files <- list.files(pattern=".dat")
for (i in length(files)){
data <-read.table(files[i],row.names=1,header=T,sep='\t')
      for in length(files){
      png('i.png') 
      pheatmap(t(data[i]), cellwidth = 32, cellheight = 14, fontsize = 5, show_colnames = T, cluster_cols = FALSE)
      dev.off()
      } 
}

Any help will be appreciated to get the code working.

Thanks

Rob

r • 2.0k views
ADD COMMENT
0
Entering edit mode

Please also post what kind of error you are getting !!!!

ADD REPLY
1
Entering edit mode
11.4 years ago
Ying W ★ 4.3k

not sure if code debugging questions would belong here vs stack exchange but I think your problem is the the png('i.png') line. you should replace it with png(paste0(i, ".png")) to prevent overwriting your pictures everytime (I assume that is the problem you are getting)

ADD COMMENT

Login before adding your answer.

Traffic: 1810 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6