On Mar 7, 2012, at 4:32 PM, karena wrote:
If a text file has rows of variable lengths. How to read the file
into R?
I think some people may suggest using 'fill=T', however, it sort of
messes
the data up, for example, in the text file:
a b c d
1 2 3 4
1 8 6
1 2 0
1 1 0
If I read in the file using ', then the
data.frame in R will be:
a b c d
1 2 3 4
1 8 6 NA
1 2 0 NA
1 1 0 NA
You need to specify what your seaprator is. If that is tab-separated,
then you need to run:
read.table("data", head=T, sep="\t", fill=T)
Could anyone tell me how to handle this?
Only if you provide reproducible data. At the moment what you pasted
into that mailing did not have tabs in it .... at least after your
mail client, and then Nabble, and then the Rhelp server had their way
with it.
David Winsemius, MD
West Hartford, CT
______________________________________________
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.