R を使用してコンピュータのファイル サイズを丸めるために、学士論文のチューターからこのコードを取得しました。コンピュータ (IOS) で彼のコード (Windows) を使用するのは問題があるようです。
私はすでにフォルダへのパスを変更しました。setwd が機能しないため、フォルダーのファイル名が空になっていると思います。
誰かが私を助けることができますか?
ありがとうございました。以下にRコードをコピーしました
library(data.table)
#Auflösung der Daten anpassen
# 1. Data is located in individual folders, which must be addressed one after the other
path_to_folders <- c("/Users/paul/Desktop/Testdaten")
folder_names <- list.files(path_to_folders)
for(i in 1:length(folder_names)){
tryCatch({
# Access relevant data set
path_to_data <- paste(path_to_folders, "\\", folder_names[i], sep="")
setwd(path_to_data)
filenames <- list.files(path_to_data, pattern =".txt")
for(k in 1:length(filenames)){
spc_txt_file<-filenames[k]
spc_txt_dat<-read.table(spc_txt_file)
spc_txt_dat<-spc_txt_dat[,c(1:3)] # only xyz
spc_txt_dat <- round(spc_txt_dat, 2) # Specifying the decimal place
spc_txt_dat <- unique(spc_txt_dat) # Double selection
spc_txt_name<-substr(spc_txt_file, 1,5)
utils::write.table(spc_txt_dat, file = paste0(path_to_data,'/',spc_txt_name, '_gerundet.txt'),
row.names = F, col.names = F)}
}, error=function(e){cat("ERROR :",conditionMessage(e), "\n")})
}