r - 需要使用 Purrr::map_dfc 传递数据文件
问题描述
我的代码对我的 90% 的 H5 文件都非常有效。但是,我有 200 多个文件中有 3 个文件有一列数据和一个额外的条目,而不是 3212,它有 3213。我不能进入并删除文件中的这些。我只需要完全忽略该特定文件或删除额外的条目。你已经尝试过 pmap 和 map2 没有成功。它循环超过 5 个文件,然后将它们全部打开到一个数据帧中。我尝试过使用可能(),但什么也没做。我不确定如何使用 tryCatch
i<- 0
for(i in seq_along(files)) {
name <- paste0("file_", i)
assign(name,files[[i]])
}
H5_files<-lapply(files, H5Fopen)
file_list <- h5ls(H5_files[[1]])
TM_AU<- purrr::map2(H5_files, "/Diagnostics/TM_AU", h5read)
units <- purrr::map_char(TM_AU, "Units", H5Fopen)
# time is contructed from the dt and t0 variables. So that the shots line up for comparison it must only be called once.
possible_length <-possibly(H5Fopen, otherwise= NA)
TM_AU_df <-purrr::map_dfc(TM_AU, "Data", H5Fopen, possible_length) # I get the argument length here
# Error: Argument 3 must be length 3312, not 3313
dt <-purrr::map_dbl(TM_AU, "dt", H5Fopen)
t0 <-purrr::map_dbl(TM_AU, "t0", H5Fopen)
解决方案
推荐阅读
- javascript - reactjs doc提到useEffect挂钩中的延迟事件,这是什么意思?
- spring-boot - 如何使用代理方法使用内部 REST 服务?
- c# - 试图找到在图中导航一组边的最快方法
- java - JavaFX 元素是否响应事件?
- zsh - `python3()` 有什么作用?
- java - 使用通用返回类型的 Spring webclient
- php - 验证不返回错误 Laravel 7
- angular - Angular7:将 JSON 数据导出为 CSV
- amazon-web-services - 将文件复制到 S3 中的文件夹最终位于父文件夹
- antlr - 在 Antr 中实现 IF Else for、while 循环和逻辑语句