3
URLから連結テキストファイルを取得しようとしていますが、htmlや別のフォルダでこれを行う方法がわかりません。rbind txtファイルfrom online directory(R)
これは私が試したコードですが、テキストファイルのみを表示し、thisのようなhtmlコードがたくさんあります。テキストファイルを1つのCSVファイルに結合するにはどうすればよいですか?
library(RCurl)
url <- "http://weather.ggy.uga.edu/data/daily/"
dir <- getURL(url, dirlistonly = T)
filenames <- unlist(strsplit(dir,"\n")) #split into filenames
#append the files one after another
for (i in 1:length(filenames)) {
file <- past(url,filenames[i],delim='') #concatenate for urly
if (i==1){
cp <- read_delim(file, header=F, delim=',')
}
else{
temp <- read_delim(file,header=F,delim=',')
cp <- rbind(cp,temp) #append to existing file
rm(temp)# remove the temporary file
}
}
ありがとうございました! – Dean
こんにちは、何らかの理由で列9(Solar)に正しい値がありません。それは最後の桁のみを持つ。それが影響を受けた唯一の列です。これを修正する方法はありますか? – Dean
これは 'fwf_empty'の問題であるようです。これは、列の終わりと始まりを決定する関数です。私は理想的ではありませんが、あなたのために働く必要があります手動修正を作成しました。 – jmartindill