inst/updateAPIInfo/mkValidOpts.R

library(XML)

updateValidOptions =
    #
    # This is not used directly in the package but is used
    # to generate the ValidOptions variable in the package
    # that is used by the valid_opts() function.
    # It reads the names of the valid parameters from the API documentation page
    # so that they are "up-to-date".  Run this function in this
    # directory of the package with
    #  updateValidOtions()
    # This regenerates the file ValidOpts.R in the R/ directory.
    #
function(filename = "../../R/ValidOpts.R")    
{
    tbls <- readHTMLTable("http://et.water.ca.gov/Rest/Index", stringsAsFactors = FALSE)#[c("Daily Data Items", "Hourly Data Items")  ]

    if(length(filename) && !is.na(filename) && filename != "") {
       txt = capture.output(dput(tbls))
       txt = gsub("[‘’]", "'", txt)
       cat("ValidOptions <- ", txt, sep = "\n", file = filename)
    }
    tbls
}
mespe/Rcimis documentation built on May 22, 2019, 6:53 p.m.