ディレクトリの複数Csvを読み込み
getwd()
files <- list.files(path = " パスを入力", pattern = "*.csv", full.names = F)
dat <- sapply(files, read.csv, fileEncoding = "utf8", simplify=FALSE) %>% bind_rows(.id = "id")
dat %>% sample_n(50) %>% view()
ファイル操作系(移動・コピー・ディレクトリ作成)
file.choose()
file.create("", showWarnings = TRUE)
file.copy(from = file.choose(), to = ディレクトリ)
file.copy(from = file.choose(), to = choose.dir())
MoveFile( src$, dst$ )
file.remove("ファイル名")
file.rename("元のファイル名", "変更後のファイル名")
dir.create("./temp", showWarnings = TRUE)
file.exists("ファイル名")
fileUrl <- "https://www.e-stat.go.jp/SG1/estat/GL08020103.do?_xlsDownload_&fileId=000005017344&releaseCount=2"
download.file(fileUrl, "033kokuseida01.xls")
for (i in 1:length(txt.files) {
data <- read.table(txt.files[i])
}
#ダミー変数を作成する #if X1==ABC, then storing X2==1, else Storing X2==0
ifelse(df$X1=="ABC",1,0)