I am writing code for multiple people in my group to use. Some are very familiar with R and others are not. So I need to write code that is rather user friendly. The less the end user has to type the better. I need to access H5 files from multiple files( which I cannot combine) and having switch cases for the multiple files that will need to be pulled from the 100 files in each folder.
I am able to open all the files on my own with no problem and do the needed calculations and export the graphs.
This is the easy part
# a crap ton of libraries have been cut out and I took out my while loop
askUser_file_x <- readline(prompt="Please, type on DS you wish to analyze, else type none (format DS##): ")
x <- str_extract(askUser_file_x, "(?<=DS)[0-9]+")
x <-as.numeric(x)
if (x==23){
setwd("C:/.../H5files/08/14/")
}else if (x>=24 & x<=26){
setwd("C:/..../H5files/08/15/")
}else if (x>=27 & x<=29){
setwd("C:/.../H5files/08/19/")
}else if (x>=30 & x<=36){
setwd("C:/.../H5files/08/20/")
}else if (x>=01 & x<=06){
setwd("C:/..../H5files/08/21/")
}else if (x>=37 & x<=44){
setwd("C:/..../H5files/08/21/")
}else if (x>=07 & x<=18){
setwd("C:/..../H5files/08/26/")
}else if (x>=19 & x<=22){
setwd("C:/...../H5files/08/27/")
}else if (x>=45 & x<=46){
setwd("C:/...../H5files/08/28/")
}else if (x>=47 & x<=50){
setwd("C:/....../H5files/08/29/")
}else
print( "DataSet does not exist")
switch(askUser_file_x,
DS01= (file <-paste0("VA_000",c(282:286))),
DS03= (file <-paste0("VA_000",c(266:271))),
DS04= (file <-paste0("VA_000",c(272:276))),
DS05= (file <-paste0("VA_000",c(277:281))),
DS06= (file <-paste0("VA_000",c(290:294))),
DS07= (file <-paste0("VA_000",c(316:320))),
DS08 =(file <-paste0("VA_000",c(321:325))),
DS09 =(file <-paste0("VA_000",c(326:330))),
DS10 =(file <-paste0("VA_000",c(331:335))),
DS11 =(file <-paste0("VA_000",c(295:300))),
DS12 =(file <-paste0("VA_000",c(301:305)))
)
files <-paste0(file, ".h5")
H5_files<-lapply(files, H5Fopen)
askUser_test_1 <- readline(prompt="Please, select from list: ")
x_str_test_1 <- as.character( str_extract(askUser_test_1, "(Vout_TM)[0-9]+") )
# shows data in raw form
#lists all the available sub directories in the .h5 file
All of that was easy works great no problems. But now I need to drill deeper in the by subsetting over a loop it just does not work. And I am at a loss what to do.
# h5ls(H5_files[[1]])
for (i in H5_files){
File1<-H5Fopen(H5_files[[i]], askUser_test_1)#access the file for comparision.
File2<-h5read(H5_files[[i]], askUser_test_1)# the acessed files must be of the same type
# File3<-h5read(H5_files[[3]], askUser_test_1) this works if it is run independently so I know that I have not made mistakes in the previous code.
I have tried both H5Fopen and h5 read if the numbers are in there it works but the i does not.
This is the error that I get Error in H5_files[[i]] : invalid subscript type 'S4'. If some one could point me in the right direction that would be great. Thanks in advance