我正在尝试从 matlab v7 读取 .mat 文件。
我尝试了以下代码,期望 lapply 为 mydata 分配一个包含每个文件中的数据的列表。
> library(rhdf5)
> base :: setwd('filepath')
> filenames <- base::list.files(
> path = ('filepath'),
> recursive = TRUE,
> pattern = "*.mat"
> )
> mydata <- lapply(filenames, function(x) h5read(x))
相反,我收到了以下代码:
> Error in H5Fopen(file, flags = flags, fapl = fapl, native = native) :
> HDF5. File accessibilty. Unable to open file.
我也查看了Bioconducter网站,但我只能找到下载数据的解决方案,而不是本地存储的数据。
我能够通过使用另一个名为 raveio 的包来解决这个问题。发布作为答案,以防其他人遇到类似问题!
library(raveio)
base :: setwd("filepath")
filenames <- base::list.files(
path = ("fiepath"), # Insert your relevant filepath here
recursive = TRUE,
pattern = "*.mat"
)