Skip to contents

Fetches the UK House Price Index for several regions and returns a wide data frame with one measure (e.g. average price or annual % change) as a column per region. Useful for regional comparison charts.

Usage

ukh_hpi_compare(
  regions,
  measure = "avg_price",
  from = NULL,
  to = NULL,
  refresh = FALSE
)

Arguments

regions

Character vector of region slugs, GSS codes, or names.

measure

Character. Which measure to return. One of "avg_price", "hpi", "pct_change_annual", "pct_change_monthly", or "sales_volume". Default "avg_price".

from, to

Optional character or Date. Date range.

refresh

Logical. Re-download even if cached? Default FALSE.

Value

A wide data frame with a date column and one column per region.

See also

Other house price index: ukh_hpi(), ukh_transactions()

Examples

# \donttest{
op <- options(ukhousing.cache_dir = tempdir())

prices <- ukh_hpi_compare(
  c("london", "manchester", "newcastle-upon-tyne"),
  measure = "avg_price",
  from = "2015-01-01"
)
#>  Downloading UK HPI for "london"...
#>  Downloading UK HPI for "manchester"...
#>  Downloading UK HPI for "newcastle-upon-tyne"...
head(prices)
#>         date london manchester newcastle-upon-tyne
#> 1 2015-01-01 431270     128873              142419
#> 2 2015-02-01 433331     128736              143341
#> 3 2015-03-01 433259     128771              144666
#> 4 2015-04-01 439403     128869              147495
#> 5 2015-05-01 445154     131114              148367
#> 6 2015-06-01 449070     131653              150261

options(op)
# }