コードの1つのステップで、テキストファイルのフォルダーを読み取り、それをdtmに変換するのに問題があります。問題は、何らかの理由で、私のコンピュータがディレクトリ内のテキストファイルとの接続を断続的にしか確立できないことです。返されるエラーは次のとおりです。
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file '[file name]': No such file or directory
ただし、これらのファイルは、Pythonだけでなく、任意のテキストエディタで簡単に開くことができます。他の人ではなく時々接続を確立できるかもしれない理由はありますか?私のコードは以下の通りです:
files <- as.character(list.files(path="[file path]"))
readLines(files[1]) #here is where the error occurs, for example
n <- length(files) #this is my loop
subtitles <- character(n)
subtitle <- character(1)
for (i in 1:n){
subtitle <- as.character(readLines(files[i]))
subtitle <- iconv(subtitle, to="UTF8")
subtitle <- tolower(subtitle)
subtitle <- as.character(paste(subtitle, collapse=" "))
subtitles[i] <- subtitle[1]
}