我的数据来自此URL,具有以下结构:
93193KFAT FAT2013123016150015 NP [0000 ] 0.00 39999 29.791
93193KFAT FAT2013123016160016 NP [0000 ] 0.00 39999 29.791
93193KFAT FAT2013123016170017 NP [0000 ] 39999 29.791
93193KFAT FAT2013123016170017 NP [0000 ] 0.00 39999 29.791
所以,如果你看到这个:
当我将其加载到R中时,它会给出错误:
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 377 did not have 12 elements
你如何解决这个问题?这样我可以直接从URL打开这个没有任何问题?
谢谢!
> read.fwf(ftp://ftp.ncdc.noaa.gov/pub/data/asos-onemin/6406-2013/64060KFAT201312.dat)
Error: unexpected '/' in "read.fwf(ftp:/"
trying URL 'ftp://ftp.ncdc.noaa.gov/pub/data/asos-onemin/6406- 2013/64060KFAT201312.dat'
using Synchronous WinInet calls
Error in download.file(url, downloadPath) :
cannot open URL 'ftp://ftp.ncdc.noaa.gov/pub/data/asos-onemin/6406-2013/64060KFAT201312.dat'
In addition: Warning message:
In download.file(url, downloadPath) : InternetOpenUrl failed: ''
Error in download.file(url, downloadPath) : unsupported URL scheme
1)尝试网址(" ....)。我收到错误:
Error in url("ftp.ncdc.noaa.gov/pub/data/asos-onemin/6406-2013/64060KFAT201312.dat") :
unsupported URL scheme
2)我尝试使用库(RCurl)并执行:getURL(" ...)。我收到错误:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file [... and R shows the data in the url ]
答案 0 :(得分:2)
有些事情如下:
a <- read.fwf("ftp://ftp.ncdc.noaa.gov/pub/data/asos-onemin/6406-2013/64060KFAT201312.dat",
widths=c(9, 20, 2, 3, 9, 5, 6, 7))