Need to open H5 files

Interesting question and pretty obvious why a reproducible example, called a reprex can be impractical sometimes.

I'll go out on a limb and guess that you're coming to R from a procedural/imperative programming background and you think of i as simply an iterator that is going to take on a succession of integer values equal to the length of H5_files. But that's not what's happening in the code.

Inspect the structure of HS_files


and I'm darned sure you'll see that these are S4 objects, not integers. And, of course, you need an integer to subset, not an S4 object.

But that's only the immediate obstacle. Although you can probably fix it with syntactical R code, I'd suggest instead writing a function to deal with a single H5 object to get the result you want, and then use purrr::map to apply it to the collection of those.

Come on back if I've sent you down a rabbit hole.