Re: [R] Reading a tab delimted file of varying length using read.table

2016-01-17 Thread Uwe Ligges
Dear Rolf, I'll take a look how to fix it tomorrow, your proposal is very welocme, of course, Best, Uwe On 18.01.2016 00:01, Rolf Turner wrote: On 18/01/16 10:48, Uwe Ligges wrote: This is not a tab delimited file (as you apparently assume given the code), but a fixed width format, hence I

Re: [R] Reading a tab delimted file of varying length using read.table

2016-01-17 Thread Pradeep Bisht
A Big thanks to everyone to help me solve this problem . My bad I assumed the file is delimited by tab which it was not . Its a fixed width file and the code that Uwe gave is just perfect . It was cleaver to skip the first row since the delimiter cannot be specified in this case .I added few more t

Re: [R] Reading a tab delimted file of varying length using read.table

2016-01-17 Thread Rolf Turner
On 18/01/16 10:48, Uwe Ligges wrote: 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

Re: [R] Reading a tab delimted file of varying length using read.table

2016-01-17 Thread Uwe Ligges
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) <- a

Re: [R] Reading a tab delimted file of varying length using read.table

2016-01-17 Thread Ben Tupper
Hi Pradeep, Any software would be challenged to determine the boundaries between your columns. ff <- 'http://data.princeton.edu/wws509/datasets/divorce.dat' txt <- readLines(ff) head(txt) # [1] " idheduc heblack mixed years div " " 9 12-15 yearsNo N

Re: [R] Reading a tab delimted file of varying length using read.table

2016-01-17 Thread Rolf Fankhauser
Hello Pradeep I downloaded divorce.dat but I could not find tabs between the columns. You defined tab as separator, so your columns should be separated by tabs. Therefore read.table reads the whole first line and wants to save the result as numeric because you defined the first column as numeric

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

2016-01-17 Thread Pradeep Bisht
Hello Experts , Being a SAS developer I am finding it difficult to perform some of data cleaning in R that are quite easy to perform in SAS . I have been trying to read a .dat file and after a lot of attempts have failed to find a solution . Maybe R doesn't have the functionality right now or I