Hi: Maybe something like this?
txt <- "Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl (target is right word)\tl\tPressed\tl (target is right word)\tC\t3111\t\t\t\t\t" txtdf <- as.data.frame(rbind(txt, txt, txt, txt, txt)) # create toy data frame res <- t(as.matrix(apply(txtdf, 1, function(x) strsplit(x, '\t')[[1]]))) > res [,1] [,2] [,3] [,4] [,5] txt "Main Group" "1000" "MP Test" "MP Test, 1" "Audio (1, f1-qaddara.aiff)" txt "Main Group" "1000" "MP Test" "MP Test, 1" "Audio (1, f1-qaddara.aiff)" txt "Main Group" "1000" "MP Test" "MP Test, 1" "Audio (1, f1-qaddara.aiff)" txt "Main Group" "1000" "MP Test" "MP Test, 1" "Audio (1, f1-qaddara.aiff)" txt "Main Group" "1000" "MP Test" "MP Test, 1" "Audio (1, f1-qaddara.aiff)" [,6] [,7] [,8] [,9] txt "l\n(target is right word)" "l" "Pressed" "l (target is right\nword)" txt "l\n(target is right word)" "l" "Pressed" "l (target is right\nword)" txt "l\n(target is right word)" "l" "Pressed" "l (target is right\nword)" txt "l\n(target is right word)" "l" "Pressed" "l (target is right\nword)" txt "l\n(target is right word)" "l" "Pressed" "l (target is right\nword)" [,10] [,11] [,12] [,13] [,14] [,15] txt "C" "3111" "" "" "" "" txt "C" "3111" "" "" "" "" txt "C" "3111" "" "" "" "" txt "C" "3111" "" "" "" "" txt "C" "3111" "" "" "" "" The rownames are an artifice of having copied txt five times to create the df. HTH, Dennis On Fri, Jun 4, 2010 at 11:42 AM, Kevin Burnham <kburn...@gmail.com> wrote: > Thanks, that worked great, but I am having trouble generalizing it to my > entire data set for some reason. > > I have 318 rows like this: > > "Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl > (target is right word)\tl\tPressed\tl (target is right > word)\tC\t3111\t\t\t\t\t" > > and the command: > mydata <- matrix(strsplit(x, '\t')[[1]], nrow=1) > > gives me a matrix with only the 1st row of the data. I have tried playing > around with it, but so far the best I can do is get 318 copies of row 1. > > How can I get a matrix with all 318 rows and 15 columns split by the '\t'? > > Thanks again. > > kevin > > > On Thu, Jun 3, 2010 at 2:39 PM, jim holtman <jholt...@gmail.com> wrote: > > > If you want a matrix, then just create one from the data you have: > > > > mydata <- matrix(strsplit(x, '\t')[[1]], nrow=1) > > > > On Thu, Jun 3, 2010 at 1:30 PM, Kevin Burnham <kburn...@gmail.com> > wrote: > > > Would somebody please help me break this row: > > > > > > "Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl > > > (target is right word)\tl\tPressed\tl (target is right > > > word)\tC\t3111\t\t\t\t\t" > > > > > > into multiple columns along the \t separator? > > > > > > When I try the strsplit (x,"\t") command I get: > > > > > > [[1]] > > > [1] "Main Group" "1000" "MP > > > Test" "MP Test, 1" "Audio (1, > > > f1-qaddara.aiff)" > > > [6] "l (target is right word)" "l" > > > "Pressed" "l (target is right word)" > > > "C" > > > [11] "3111" "" > > > "" "" "" > > > > > > Which which is closer to what I need, but still not in columns. > > > > > > Thanks, > > > Kevin > > > > > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > > 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. > > > > > > > > > > > -- > > Jim Holtman > > Cincinnati, OH > > +1 513 646 9390 > > > > What is the problem that you are trying to solve? > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.