[R] Read multiple files into dataframe?

Douglas M. Hultstrand dmhultst at metstat.com
Tue Sep 1 22:24:48 CEST 2009


Hello,

I am fairly new to R programming and am stuck with the following problem.

I am trying to read in multiple files (see attached file or at end of 
email), the files all have the same general header information and 
different precipitation (avgppt) and area (areasqmi) values.  Some times 
the number of records are different in the files.

I want to read in all files (.stdsummary), and create a dataframe that 
contains the area and precipitation for each file (files are different 
duration), and supply a header name that represents the duration (sixth 
line down in header information or extracted from data file 
"da_zone1_15hr_1166.stdsummary"). 

For example, this is what the final dataframe would look like for 1hr, 
3hr, and 15hr datafiles:
1hrppt      1hrarea    3hrppt      3hrarea    15hrppt      15hrarea 
3.8    0    6.86    0    7.67    0
3.71    1    6.78    1    7.6    1
3.69    5    6.72    5    7.52    5
3.56    10    6.55    10    7.32    10
3.33    20    6.17    20    6.91    20
2.87    50    5.25    50    5.9    50
2.45    100    4.35    100    5.02    100
1.94    200    3.34    200    4.09    200
1.67    300    2.78    300    3.55    300

The end result is to perform QC statistics and then plot each set of 
data.  Also, is there away to create a dataframe that has different # of 
records?

Datafile example of file below:

Storm number: 1166
Zone number: 1 (ALL zones)
Number of stations: 172
Total analyzed area (sq mi):     5360.8
Average station density (stns per 1000 sq mi):   na
Duration window (hours): 15
CPP beg hour index: 1
CPP end hour index: 15
Ishohyet interval step (inches): 0.2
Standard area size summary
Begin run date/time: Tue Aug 25 01:17:43 2009
avgppt,  areasqmi
00007.67,0000000.00
00007.60,0000001.00
00007.52,0000005.00
00007.32,0000010.00
00006.91,0000020.00
00005.90,0000050.00
00005.02,0000100.00
00004.09,0000200.00
00003.55,0000300.00
00002.96,0000500.00
00002.27,0001000.00
00001.64,0002000.00
00000.82,0005000.00
00000.77,0005360.00

-- 
---------------------------------
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice: 970.686.1253
email: dmhultst at metstat.com
web: http://www.metstat.com
---------------------------------

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: da_zone1_15hr_1166.stdsummary
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090901/0ce0457f/attachment-0001.pl>


More information about the R-help mailing list