[R] Strange csv parsing problem
Hadley Wickham
hadley at rice.edu
Thu Apr 8 03:26:46 CEST 2010
> url <- "http://dl.dropbox.com/u/41902/22240.csv"
>
> read.csv(url)[, 1]
[1] "oppose" NA "oppose" "support"
> read.csv(url, header = F)[, 1]
[1] "url"
[2] "http://maplight.org/us-congress/bill/109-hr-5825/387248"
[3] "http://maplight.org/us-congress/bill/110-hr-3546/378743"
[4] "http://maplight.org/us-congress/bill/111-s-908/365504"
[5] "http://maplight.org/us-congress/bill/111-hr-3245/373358"
>
> count.fields(url, sep = ",")
[1] 11 11 11 12 11
This seems like it should be an error - I suspect it might be caused
by the escaped quote (\") in line 4 column 432 causing the first
column to be treated as column names:
> read.csv(url, row.names = NULL)[, 1]
[1] "http://maplight.org/us-congress/bill/109-hr-5825/387248"
[2] "http://maplight.org/us-congress/bill/110-hr-3546/378743"
[3] "http://maplight.org/us-congress/bill/111-s-908/365504"
[4] "http://maplight.org/us-congress/bill/111-hr-3245/373358"
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
More information about the R-help
mailing list