Hi all, I have a matrix like this: 188556644 225588666 558888555 I try to read the table using read table but if I put sep="" I have seen it expects a white space, is there a "sep" option to read this matrix so each single number is a position of the matrix You see this matrix would be an 3x9 matrix I tried other option but also didn´t worked. If sep = "" (the default for read.table) the separator is ‘white space’, that is one or more spaces, tabs, newlines or carriage returns. [[alternative HTML version deleted]]
Trying To learn again <tryingtolearnagain <at> gmail.com> writes:> 188556644 > 225588666 > 558888555 > > I try to read the table using read table but if I put sep="" I have seen it > expects a white space, is there a "sep" option to read this matrix so > each single number is a position of the matrix?read.fwf, I think ...
On Jun 28, 2011, at 3:47 PM, Trying To learn again wrote:> Hi all, > > I have a matrix like this: > > 188556644 > 225588666 > 558888555 > > I try to read the table using read table but if I put sep="" I have > seen it > expects a white space, is there a "sep" option to read this matrix so > each single number is a position of the matrixNo. You want read.fwf ... which I thought was in the foreign package but it appears to be in base. > nchar(188556644) [1] 9 > Lines <- textConnection("188556644 + 225588666 + 558888555") > read.fwf(Lines, rep(1,9)) V1 V2 V3 V4 V5 V6 V7 V8 V9 1 1 8 8 5 5 6 6 4 4 2 2 2 5 5 8 8 6 6 6 3 5 5 8 8 8 8 5 5 5> > You see this matrix would be an 3x9 matrix > > I tried other option but also didn?t worked. > > If sep = "" (the default for read.table) the separator is ?white > space?, > that is one or more spaces, tabs, newlines or carriage returns. > > [[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.David Winsemius, MD West Hartford, CT
On Jun 28, 2011, at 3:56 PM, David Winsemius wrote:> > On Jun 28, 2011, at 3:47 PM, Trying To learn again wrote: > >> Hi all, >> >> I have a matrix like this: >> >> 188556644 >> 225588666 >> 558888555 >> >> I try to read the table using read table but if I put sep="" I have >> seen it >> expects a white space, is there a "sep" option to read this matrix >> so >> each single number is a position of the matrix > > No. You want read.fwf ... which I thought was in the foreign package > but it appears to be in base. > > > nchar(188556644) > [1] 9 > > Lines <- textConnection("188556644 > + 225588666 > + 558888555") > > read.fwf(Lines, rep(1,9)) > V1 V2 V3 V4 V5 V6 V7 V8 V9 > 1 1 8 8 5 5 6 6 4 4 > 2 2 2 5 5 8 8 6 6 6 > 3 5 5 8 8 8 8 5 5 5... and wrap data.matrix around that result if you really do want a matrix.> >> >> You see this matrix would be an 3x9 matrix >David Winsemius, MD West Hartford, CT
try this:> x <- read.fwf(textConnection("188556644+ 225588666 + 558888555"), width = rep(1,9))> > xV1 V2 V3 V4 V5 V6 V7 V8 V9 1 1 8 8 5 5 6 6 4 4 2 2 2 5 5 8 8 6 6 6 3 5 5 8 8 8 8 5 5 5>On Tue, Jun 28, 2011 at 3:47 PM, Trying To learn again <tryingtolearnagain at gmail.com> wrote:> ?Hi all, > > I have a matrix like this: > > 188556644 > 225588666 > 558888555 > > I try to read the table using read table but if I put sep="" I have seen it > expects a white space, is there a "sep" option to ?read this matrix so > each single number is a position of the matrix > > You see this matrix would be an 3x9 matrix > > I tried other option but also didn?t worked. > > ?If sep = "" (the default for read.table) the separator is ?white space?, > that is one or more spaces, tabs, newlines or carriage returns. > > ? ? ? ?[[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 Data Munger Guru What is the problem that you are trying to solve?