[R] Import_from_outputfile

jim holtman jholtman at gmail.com
Thu Apr 24 04:14:21 CEST 2008


One way is to first read in the data with readLines.  This will create
a character vector of the input lines.  You can then remove the lines
you want and then use textConnect to read in the modified data:

x <- readLines(file)
x <- x[-c(2,3)]  # delete lines two and three
input <- read.table(textConnection(x), header=TRUE)

On Wed, Apr 23, 2008 at 9:29 AM, Ole Roessler
<o.roessler at giub.uni-bonn.de> wrote:
>
>   Hello,
>   I want to do some analyses with data originating from a hydrological model
>   that are saved in multiple output files.
>   I  want  to  import  the  output-files  in  R without a treatment like
>   preproceesing every output file.
>   The output file is more or less a matrix, but with additional rows in the
>   header, describing the type of data.
>   My question is:
>   1. Is there a possibility to skip the rows or start with a certain row?
>   I want to exclude row 2 and 3, so the first line become the header of the
>   list below.
>   This is the beginning of the output file to be imported.
>   YY    MM    DD    HH    "1"    "2"    "3"    "4"    "5"    tot_average
>   total runoff [mm per zone] (sum of QB, QI und QD)_submodel:unsatzon_model
>   --    --    --    --    0.1466624    0.2958042    0.2225048    0.2279085
>   0.1071202    1.0000
>   2001     1     1     1    0.055242    0.037391    0.051550    0.057681
>   0.021070    0.046036
>   2001     1     1     2    0.051288    0.032404    0.047027    0.056636
>   0.021070    0.042736
>   2001     1     1     3    0.052491    0.032937    0.048042    0.058415
>   0.021070    0.043701
>   2001     1     1     4    0.051389    0.032508    0.047136    0.056663
>   0.021070    0.042812
>   2001     1     1     5    0.050730    0.032263    0.046599    0.055585
>   0.021070    0.042278
>   Would be a great help if there is a possibility.
>   Thank you very much !
>   best regards
>   Ole
>
>   --
>
>
>   ----------------------------------------------------------------------------
>   ---
>
>
>   Ole Röà ler
>
>   PhD - student
>
>   Climatology and Landscape-Ecology Research Group
>
>   Department of Geography
>
>   University of Bonn
>
>
>   Postal Address:
>
>   Meckenheimer Allee 166
>
>   53115 Bonn
>
>   Germany
>
>
>
>   Tel.:  +49-(0)228-737895
>
>   Fax.: +49-(0)228-737506
>
>
>
>   Email: [1]o.roessler at giub.uni-bonn.de
>
>   Homepage:
>   [2]http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm
>
>
>   ----------------------------------------------------------------------------
>   -----
>
> References
>
>   1. mailto:o.roessler at giub.uni-bonn.de
>   2. http://www.giub.uni-bonn.de/loeffler/people/people_sites/roessler.htm
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list