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.

That's my interpretation
So, use tab, comma or semicolon as delimiter then it should work.

Rolf

Pradeep Bisht wrote:
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 am not looking in the right place . Here is my code .

f5=read.table("http://data.princeton.edu/wws509/datasets/divorce.dat
<http://www.linkedin.com/redir/redirect?url=http%3A%2F%2Fdata%2Eprinceton%2Eedu%2Fwws509%2Fdatasets%2Fdivorce%2Edat&urlhash=GVbR&_t=tracking_anet>
",
header=T,
sep="\t",
colClasses = c("numeric", "character", "character","character", "double",
"character" ) )
The error i get i
​s​
this .
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
scan() expected 'a real', got '912-15yearsNoNo10.546No'

Also does read.table always calls scan in background to do its job . If so
why use read.table in first place .

Pradeep​

______________________________________________
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.

Reply via email to