[英]R progress bar for reading multiple csv (tsv) files
有什么方法可以顯示導入多個 csv 文件的進度條。 這是導入代碼:列出要導入的所有字段:
temp <- list.files(pattern="*\\.tsv$")
temp
將導入特定列:
test_data <- lapply(temp,function(x){
read.csv(file = x,
sep ="\t",
fill = TRUE,
quote='',
header = FALSE
)[ ,c(287, 288, 289, 290, 291, 292, 293, 304, 370, 661, 662, 812, 813,994, 995, 1002)]
}
)
如何監控當前的進度狀態? 我只是找到了一些關於循環的建議,但沒有找到關於導入文件的建議
您可以使用progress
庫實現此目的:
library(progress) # add
temp <- list.files(pattern="*\\.tsv$")
pb <- progress_bar$new(format = " progress [:bar] :percent eta: :eta", # add
total = length(temp), clear = FALSE, width= 60) # add
test_data <- lapply(temp,function(x){
pb$tick() # add
read.csv(file = x,
sep ="\t",
fill = TRUE,
quote='',
header = FALSE
)[ ,c(287, 288, 289, 290, 291, 292, 293, 304, 370, 661, 662, 812, 813,994, 995, 1002)]
})
我用# add
注釋標記了您需要添加的行。 還有一個您可以使用的原生R
進度條,但我發現progress
版本更具可讀性、可配置性和易用性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.