1
I am using R to extract data in format .h5
. I’m getting it done.
However, they are data of 200 years, and monthly.
For now, I can only call through the program a file every month at a time, but I need to be able to make a script where I can extract the data from each file for every year, without having to do it one by one. My script is 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 was 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 to make him know that he has to call all the files .h5
and distinguish between 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, as the month gets in the "middle" of the file name, how could I call tosos the archives of the month?
I tried it like this: "_. H5" but it didn’t work. I also tried "*. H5" didn’t work either.