Hi Kate, The following: x<-read.table(text="A B C D E A 1232 0.565 B 2323 0.5656 0.5656 0.5656 C 2323 0.5656 D 2323 0.5656 E 2323 0.5656 F 2323 0.5656 G 2323 0.5656 G 2323 0.5656 0.5656 0.5656",header=TRUE,fill=TRUE)
works fine for me: x A B C D E 1 A 1232 0.5650 NA NA 2 B 2323 0.5656 0.5656 0.5656 3 C 2323 0.5656 NA NA 4 D 2323 0.5656 NA NA 5 E 2323 0.5656 NA NA 6 F 2323 0.5656 NA NA 7 G 2323 0.5656 NA NA 8 G 2323 0.5656 0.5656 0.5656 I just copied your example text into a text editor and added the "x<-read.table...". Do you really have TAB delimiters in the file you are trying to import? If so, can you do a global replace of TAB -> space in the incoming file? Jim On Sun, May 10, 2015 at 2:43 AM, William Dunlap <wdun...@tibco.com> wrote: > txt <- c("A B C D E", "A 1232 0.565", "B 2323 0.5656 0.5656 0.5656", > "C 2323 0.5656", "D 2323 0.5656", "E 2323 0.5656", "F 2323 0.5656", > "G 2323 0.5656", "G 2323 0.5656 0.5656 0.5656") > z <- read.table(text=txt, fill=TRUE, header=TRUE) > str(z) > #'data.frame': 8 obs. of 5 variables: > # $ A: Factor w/ 7 levels "A","B","C","D",..: 1 2 3 4 5 6 7 7 > # $ B: int 1232 2323 2323 2323 2323 2323 2323 2323 > # $ C: num 0.565 0.566 0.566 0.566 0.566 ... > # $ D: num NA 0.566 NA NA NA ... > # $ E: num NA 0.566 NA NA NA ... > > If your file contains extra spaces or tabs at the ends of the lines it > is possible that using sep="\t" may mess things up: using an explicit > 'sep' argument means that you have to use it consistently as a separator. > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Sat, May 9, 2015 at 8:22 AM, Kate Ignatius <kate.ignat...@gmail.com> > wrote: > >> I've tried colClasses="character", fill=T, as.is=T, header=F, >> sep="\t", read.csv; read.delim, read.csv2, read.delim2.... don't know >> what else to try. >> >> On Sat, May 9, 2015 at 11:13 AM, MacQueen, Don <macque...@llnl.gov> wrote: >> > Some indication of what you have tried would be useful. Assuming you are >> > using read.table(), then the "fill" argument of read.table() might be >> what >> > you need. If you look at the help for read.table you will find: >> > >> > From ?read.table: >> > fill: logical. If 'TRUE' then in case the rows have unequal length, >> > blank fields are implicitly added. See 'Details'. >> > >> > >> > -- >> > Don MacQueen >> > >> > Lawrence Livermore National Laboratory >> > 7000 East Ave., L-627 >> > Livermore, CA 94550 >> > 925-423-1062 >> > >> > >> > >> > >> > >> > On 5/9/15, 7:59 AM, "Kate Ignatius" <kate.ignat...@gmail.com> wrote: >> > >> >>I have some data that I've trouble importing... >> >> >> >>A B C D E >> >>A 1232 0.565 >> >>B 2323 0.5656 0.5656 0.5656 >> >>C 2323 0.5656 >> >>D 2323 0.5656 >> >>E 2323 0.5656 >> >>F 2323 0.5656 >> >>G 2323 0.5656 >> >>G 2323 0.5656 0.5656 0.5656 >> >> >> >>When I input the data it seems to go like this: >> >> >> >>SampleID ItemB ItemC ItemD ItemE >> >>A 1232 0.565 >> >>B 2323 0.5656 >> >>0.5656 0.5656 >> >>C 2323 0.5656 >> >>D 2323 0.5656 >> >>E 2323 0.5656 >> >>F 2323 0.5656 >> >>G 2323 0.5656 >> >>G 2323 0.5656 0.5656 0.5656 >> >> >> >>with the last two columns (or the two columns with vast amounts of >> >>missing data which are usually the last two = see SampleB) wrapping >> >>around - is there away to prevent this? >> >> >> >>Thanks! >> >> >> >>______________________________________________ >> >>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> >>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. >> > >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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 -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.