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
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?
Try this: x <- readLines('clipboard') newx <- as.numeric(x[setdiff(seq(length(x)), grep("^#", x))]) comment(newx) <- grep("^#", x, value = TRUE) newx comment(newx) On Thu, Aug 28, 2008 at 12:41 PM, Dani Valverde <daniel.valverde@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@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]