xtmerge: Merge 'xtdata' data frames

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function merges panel data based on their "xtdata" attributes.

Usage

1
  xtmerge(x, y, t = "year", t.x = NULL, t.y = NULL, ...)

Arguments

x

a data frame with the xtdata attribute. See 'Details'.

y

a data frame with the xtdata attribute. See 'Details'.

t

the name of the time period variable in the data frames, which propagates to t.x and t.y. Defaults to "year".

t.x

the name of the time period variable in the first dataset.

t.y

the name of the time period variable in the second dataset.

...

other methods passed to merge, typically instructions on whether to perform an inner or outer merge; xtmerge defaults, like merge, to an inner merge.

Details

The function is intended to work as merge with a safety check: it will refuse to merge data that do not carry identical formats for their unique identifiers and time periods, as it will refuse to merge data of different primary type.

If the type parameter is set to "country", the function will also try to resolve data frames with different country code formats by matching them to iso3n codes with xtcountry.

Value

a data frame

Author(s)

Francois Briatte f.briatte@ed.ac.uk

See Also

xtcountry, xtdata, merge

Examples

1
2
3
4
5
6
7
8
9
if(require(countrycode)) {
  # Load QOG demo datasets.
  data(qog.demo)
  # Load UDS democracy scores.
  UDS = get_uds()
  # Merge QOG and UDS time series.
  xt(xtmerge(qog.ts.demo, UDS))
  names(xtmerge(qog.ts.demo, UDS))
}

briatte/qogdata documentation built on May 13, 2019, 7:43 a.m.