There's probably a better way to do it, but here's one way:
require(stringr)
windows()
file_list <- list.files(pattern=".txt")
for (file in file_list)
{
dataset <- read.table(file, header=TRUE, sep="\t")
plot(dataset)
savePlot(filename=str_replace(file,".txt",""),type="png")
K.
- Original Message -
From: David Lyon
To: "r-help@r-project.org"
Cc:
Sent: Tuesday, April 2, 2013 12:13 AM
Subject: [R] please help, iteration through a list of files and plot each one
I have many files in 1 directory, file names end in .txt.
Each file has 2 columns
col1 co
I have many files in 1 directory, file names end in .txt.
Each file has 2 columns
col1 col2
2 3
3 4
4 5
5 6
I want to make a list of the file names and iterate through each plotting them
in a separate file $filename\.png with the png swapped for txt.
So far I have this, can someone help
3 matches
Mail list logo