I'm using R to extract data in .h5
format. I am getting it.
However, they are 200 years, and monthly data.
For the moment, I can only call a file every month at a time, but I need to be able to do a script where I can extract the data from each file for every year, without having to do it one by one. My script looks like this:
library(hdf5)
mydata = hdf5load ("teste_200-Q-2000-01-00-000000-g01.h5",load=FALSE)
mydata$AGB_PY
names(mydata)
I tried to concatenate and it looked like this:
library(hdf5)
ED<-c ( "01.h5","02.h5","03.h5","04.h5","05.h5","06.h5", "07.h5", "08.h5", "09.h5","10.h5","11.h5","12.h5")
ED
names(mydata)
for(i in 01:12)sum(mydata$AGB_PY)
resu<-sum(mydata$AGB_PY)
resu
agbyear = rep(NA,times=12)
for (i in 1:12){
mydata = hdf5load(ED[i],load=FALSE)
agbyear[i] = sum(mydata$AGB_PY)}
agbyear
mydata$AGB_PY<- edit(data.frame(agbyear))
write.table(agbyear,"agbyear.csv", row.names=FALSE , sep = ",")
But I wanted to know how do I make it know that you have to call all .h5
files and distinguish months and years.
Editing:
Answering the questions, the format of each file is this:
teste_200-Q-2001-01-00-000000-g01.h5
teste_200-Q-2001-02-00-000000-g01.h5
teste_200-Q-2001-03-00-000000-g01.h5
... and so on, for 200 years from 2000 to 2200.
So how does the month stay in the "middle" of the file name, how could I call the files of the month?
I tried like this: "_.h5", but it did not work. I also tried "* .h5" also did not work.