Unable to read hdf5 files in R from Matlab v7

I’m trying to read in .mat files from matlab v7.

I tried the following code, expecting lapply to assign mydata a list containing the data from each file.

> library(rhdf5)
> base :: setwd('filepath')
> filenames <- base::list.files(
>    path = ('filepath'), 
>    recursive = TRUE,
>    pattern = "*.mat"
> )
> mydata <- lapply(filenames, function(x) h5read(x))

Instead I received the following code:

> Error in H5Fopen(file, flags = flags, fapl = fapl, native = native) : 
> HDF5. File accessibilty. Unable to open file.

I’ve also looked at the Bioconducter website, but I can only find solutions for downloaded data, not locally stored data.

  • probably a file path issue, but if you’ve cleared that, maybe you could use the R.matlab package to open the file.

    – 

  • I tried using the R.matlab package previously, but these files are saved using v7, which is not compatible with R.matlab, hence the rhdf5 package. Is there a workaround for that?

    – 

  • How about contacting the maintainer of rhdf5 to see what they have to say about this

    – 

Leave a Comment