[R] Read a file

jim holtman jholtman at gmail.com
Thu Aug 28 18:31:29 CEST 2008


Is this what you want to do:

> x <- scan('clipboard', what="", sep="\n")
Read 18 items
> x
 [1] "# File created = Thursday, August 28, 2008 3:33:02 PM GMT"
 [2] "# Data set = 373  2  1  C:\\Bruker\\TOPSPIN  GABRMN"
 [3] "# Spectral Region:"
 [4] "# LEFT = 4.5 ppm. RIGHT = 0.5 ppm."
 [5] "#"
 [6] "# SIZE = 13111 ( = number of points)"
 [7] "#"
 [8] "# In the following ordering is from the 'left' to the 'right' limits!"
 [9] "# Lines beginning with '#' must be considered as comment lines."
[10] "#"
[11] "1628.40625"
[12] "1628.40625"
[13] "1964.40625"
[14] "2242.0625"
[15] "2533.5"
[16] "2937.90625"
[17] "3448.0"
[18] "3923.96875"
>


On Thu, Aug 28, 2008 at 11:41 AM, Dani Valverde <daniel.valverde at uab.cat> wrote:
> Hello,
> I have a text file with this structure:
>
> # File created = Thursday, August 28, 2008 3:33:02 PM GMT
> # Data set = 373  2  1  C:\Bruker\TOPSPIN  GABRMN
> # Spectral Region:
> # LEFT = 4.5 ppm. RIGHT = 0.5 ppm.
> #
> # SIZE = 13111 ( = number of points)
> #
> # In the following ordering is from the 'left' to the 'right' limits!
> # Lines beginning with '#' must be considered as comment lines.
> #
> 1628.40625
> 1628.40625
> 1964.40625
> 2242.0625
> 2533.5
> 2937.90625
> 3448.0
> 3923.96875
>
> Is it possible to read it with R, something like scan() but keeping the
> structure?
> Best,
>
> Dani
>
> --
> Daniel Valverde Saubí
>
> Grup de Biologia Molecular de Llevats
> Facultat de Veterinària de la Universitat Autònoma de Barcelona
> Edifici V, Campus UAB
> 08193 Cerdanyola del Vallès- SPAIN
>
> Centro de Investigación Biomédica en Red
> en Bioingeniería, Biomateriales y
> Nanomedicina (CIBER-BBN)
>
> Grup d'Aplicacions Biomèdiques de la RMN
> Facultat de Biociències
> Universitat Autònoma de Barcelona
> Edifici Cs, Campus UAB
> 08193 Cerdanyola del Vallès- SPAIN
> +34 93 5814126
>
> ______________________________________________
> 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 that you are trying to solve?



More information about the R-help mailing list