Search code examples
rtemperaturehistorical-dbcode-climate

using rWBclimate for historical data in R


I am able to get the following code to work:

    world_dat <- get_ensemble_temp(world,"annualavg",2080,2100)

but I would like to change it to historical and start in 1920,1939 (or even earlier). Unfortunately it keeps saying unused arguments

    world_dat2 <- get_historical_temp(world,"annualavg",1920,1939)

I basically want to create a world map showing historical temperatures. Any help will be greatly appreciated. Thx!


Solution

  • The reason why you get the "unused argument" error is because the arguments for these two functions are different:

    get_ensemble_temp(locator, type, start, end)
    
    get_historical_temp(locator, time_scale)
    

    For the "get_historical_temp" function, you would set time_scale="year", and then subset to the years that you want. E.g.:

    USA_dat <- get_historical_temp("USA", "year")
    USA_dat_small <- subset(USA_dat, year >= 1920 & year <= 1939,  
                     select=c(1:length(USA_dat)))
    

    The outputs of these functions are quite different, too. You will have to average and summarize the data from "get_historical_temp" to make them comparable to the output of "get_ensemble_temp"

    Also, I couldn't get your first line to work with the argument "world." According to the docs (http://cran.r-project.org/web/packages/rWBclimate/rWBclimate.pdf) you have to use a vector of all country codes in order to get the whole world's data all at once.