ebimodeling / ghgvcR

R implementation of the Greenhouse Gas Value Calculator
Other
1 stars 6 forks source link

input file config_site.xml #12

Closed yiluheihei closed 8 years ago

yiluheihei commented 9 years ago

As a pure R user, I don't understand why use a xml file as the input file, which indicates the options (such as the flux, co2) of ghgvc and input variables of ecosystems.

In my opinion, the options of ghgvc can be achieved by setting options of package ghgvcr like the following code. Apparently, once the package loaded, a default value is loaded.

options(ghgvcr_strorage = TRUE)
options(ghgvcr_flux = FALSE)
...

More details on how to setting package customized options can be seen in hadely's book R packages.

Second, the variables of ecosystem can be stored as R based data structure data.frame:

dplyr::data_frame(name = c("temperate_forest","temperate_cropland"),
                             category = c("native",category = "agroecosystem"),
                             TA = c(100, 100),
                             T_E = c(50, 50)
)

Source: local data frame [2 x 4]

                name      category    TA   T_E
               (chr)         (chr) (dbl) (dbl)
1   temperate_forest        native   100    50
2 temperate_cropland agroecosystem   100    50

each row represents a ecosystem and each col represents a variable. More important, some simple and practical packages to manipulate data.frame (hadleyverse: dplyr, plyr). It can also be easily imported, exported (csv, xls and so on) and created in R compared to original _configsite.xml.

dlebauer commented 8 years ago

Its not clear that the benefit would warrant the amount of time this would take. But if you would like to do this please re-open and submit a pull request.