[R] Help on read in a txt file
jim holtman
jholtman at gmail.com
Fri Apr 25 04:30:05 CEST 2008
You can read the first line in and determine which of the columns
contain the names you want to use and then create the parameters for
'colClasses' to control which columns you want to read. Or you can
just read in all the data and then delete the columns you don't need.
On Thu, Apr 24, 2008 at 10:03 PM, ss <affysnp at gmail.com> wrote:
> Thanks Jim.
>
>
> I got this:
>
> > A<-read.table("a.txt", sep="\t", fill=TRUE)
>
> > dim(A)
> [1] 33623 592
> > x <- count.fields("a.txt", sep="\t")
> which(x != 592) # print out the lines that are not correct
> > which(x != 592) # print out the lines that are not correct
> [1] 31279 31281 33625
> >
>
> Actually, I just need from the txt file to grab 83 columns whose column
> names have the pattern '_A01/Ratio'.
>
> For instance, I am listing the column names of the first 23 columns and I
> only need
> the columns ends with '_A01/Ratio'. So is there a way to get around reading
> in all
> the data first?
>
> Thanks,
> Alex
>
>
> Database ebi.ac.uk:Database:ensembl
> Database ebi.ac.uk:Database:locus
> Database ebi.ac.uk:Database:refseq
> Database ebi.ac.uk:Database:tigr_thc
> Database www.chem.agilent.com:Database:agp
> Reporter group
> Reporter identifier
> Reporter name
> Reporter sequence type
> MBA: US14702370_16012391010920_S01_A01/Log(Ratio)
> MBA: US14702370_16012391010920_S01_A01/Ratio
> MBA: US14702370_16012391010920_S01_A01/Fold Change
> MBA: US14702370_16012391010920_S01_A01/Log(Error)
> MBA: US14702370_16012391010920_S01_A01/P-Value
> MBA: US14702370_16012391010920_S01_A01/Intensity 1
> MBA: US14702370_16012391010920_S01_A01/Intensity 2
> MBA: US14702370_16012391010525_S01_A01/Log(Ratio)
> MBA: US14702370_16012391010525_S01_A01/Ratio
> MBA: US14702370_16012391010525_S01_A01/Fold Change
> MBA: US14702370_16012391010525_S01_A01/Log(Error)
> MBA: US14702370_16012391010525_S01_A01/P-Value
> MBA: US14702370_16012391010525_S01_A01/Intensity 1
> MBA: US14702370_16012391010525_S01_A01/Intensity 2
>
>
>
>
>
> On Thu, Apr 24, 2008 at 9:27 PM, jim holtman <jholtman at gmail.com> wrote:
> > It seems to indicate that you don't have 592 columns on all lines.
> > Try the following to see how many columns are in each line:
> >
> > x <- count.fields("A.txt", sep="\t")
> > which(x != 592) # print out the lines that are not correct
> >
> > You might also try:
> >
> > read.table("a.txt", sep="\t", fill=TRUE)
> >
> >
> >
> >
> > On Thu, Apr 24, 2008 at 8:32 PM, ss <affysnp at gmail.com> wrote:
> > > Dear list,
> > >
> > > Hello! I had a problem of reading in a txt file and need your help.
> > > The txt file, called A, comprises of 592 columns and 34179 rows.
> > > I need to note that for some cells of A , A[i,j], are blank.
> > >
> > > I used read.table() and got the warning message:
> > >
> > > > A<-read.table(file="A.txt",sep="\t")
> > > Warning message:
> > > In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
> > > number of items read is not a multiple of the number of columns
> > > > dim(A)
> > > [1] 33623 592
> > >
> > > However, as some rows were missed because the original number
> > > of rows is 34179, after read.table(), it was decreased to 33623.
> > > I have no idea whether it has anything to do with the warning message.
> > >
> > > Do you have any suggestions for this problem?
> > >
> > > Thanks much,
> > > Alex
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > 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?
> >
>
>
--
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