Entering edit mode
8.7 years ago
Korsocius
▴
250
I am trying to plot graphs by loop.
Input data: Tables, which have same ending *depth.txt
, there is 2 tab delimited columns in table
Baba 58.38
Tata 68.38
Mama 30.80
jaja 88.65
OUTPUT: I would like to get jpeg file with plot for each *depth.txt
(name will be same name like tables) for all files (axis x will be first column from table and axis y will be second column)
I create part of script but it doesn't work..
files <- list.files(path="/home/fil/Desktop/", pattern="*depth.txt", full.names=T,recursive=FALSE)
for (i in 1:length(files)) {
plot(read.table(files[i],header=F,sep="\t")$V1,read.table(files[i],header=F,sep="\t")$V2)
dev.copy(jpeg,filename=files[i])
dev.off() }
But it doesn't work(I received only one .pdf file, where are two graphs, first one is good and second graph has weird index values on both axis and this file have name Rplots.pdf). Could you help me please. I am beginner with R.
Thanks a lot