Skip to content
Prev 357730 / 398500 Next

Reading a tab delimted file of varying length using read.table

This is not a tab delimited file (as you apparently assume given the 
code), but a fixed width format, hence I'd try:

url <- "http://data.princeton.edu/wws509/datasets/divorce.dat"
widths <- c(9, 13, 10, 8, 10, 6)
f5 <- read.fwf(url, widths = widths, skip = 1, strip.white = TRUE)

names(f5) <- as.character(unlist(read.fwf(url, widths = widths, 
strip.white=TRUE, n=1)))

Not sure why reading it simply with header=TRUE des not work, but no 
time to investiagte this now.

Best,
Uwe Ligges
On 17.01.2016 16:31, Pradeep Bisht wrote: