Off topic:Plot graphs in R by loop and save it like jpeg
0
0
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

plot R • 19k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 3953 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