Read multiple text files using R

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Read multiple text files using R

damith
Hi,

I am reading the attached .txt file using the R code below. I have 2200 txt files like this with different station IDs. I need to output only the year for peak flow data available. For example,

Year     Peak
1929   4050
1940   7000
1958   4050
...

Can somebody help me to modify this code to achive this.

My R code is shown below.

rm(list=ls(all=TRUE))
iPath <- 'C:/Desktop/flow_raw/Region-03/'
mydata <- read.table("02053200-PeakFlow-uptoWY2015.txt", sep="\t", header=TRUE)
out <- mydata[c(3,5)]



02053200-PeakFlow-uptoWY2015.txt