在文本文件启动时忽略几行文本后从文本文件中提取列

时间:2015-03-10 00:01:57

标签: r read.table

我需要从名称为" Apure.asc"的文本文件中访问列中的数据。 我不能在它上面使用read.table或read.csv,因为它在启动时包含一些额外的文本,这使得R很难将其作为表或csv文件打开。我也尝试过使用adehabitat库中的import.asc函数,但它似乎没有用。

文本文件如下所示:

TANKEXE: Sugawara-IHE tank model. Development: D.P. Solomatine
Output to file: D:\Work from Home\Apure53.ASC
Input CAL file: D:\Work from Home\Apure53.CAL  (53 time points)
Input PIN file: D:\Work from Home\g.pin  with values:
      8820.7440,48.7801,0.0215,0.0361,0.0436,0.0050,915.2973,113.4371, 
Calculated error value(s) :  
(3) Weighted root mean squared error        :       21.0927

Time       ObservedCalculated runoff, Water balance
 1,         5.3482,        76.7017,     1027.7425
 2,         4.7455,        67.4817,      954.3219
 3,         3.9938,        58.9400,      884.5183
 4,         3.5208,        51.0347,      818.1752

有关如何从此类文件访问列数据的任何建议。

1 个答案:

答案 0 :(得分:0)

这样的事情应该有效,

read.csv("Apure.asc", skip=7, strip.white=TRUE) # 7 should match number of non-data, non-blank lines in header