Skip to content

S4 development branch #7

@briatte

Description

@briatte

Hi,

Here's a draft S4 class that creates a subclass of data.frame to implement functions for panel data and time series manipulation, or for any dyadic data.

Contents

  • CountryID by @christophergandrud (wraps around countrycode by @vincentarelbundock, with edits)
  • MoveFront from DataCombine by @christophergandrud
  • class-HomogList and subclass_homog_list from DataFrameConstr by @jrnold
  • class-psData (hacked from DataFrameConstr by @jrnold)
  • constrained_data_frame from DataFrameConstr by @jrnold
  • debt.rda (demo Reinhart and Rogoff data)
  • get_data and a bunch of get (download) functions for e.g. Polity 4 and QOG data
  • panel with functions by @zmjones
  • utils (with snippets by more authors)

I'm sure many more people have written useful code for working with panel data, including for visualization purposes—the package should probably also look in that direction, and the draft includes a Reinhart and Rogoff plot.

Output

# install
devtools::install_github("briatte/psData")
library(psData)

# example
data(debt)

The object is of class data.frame:

> head(debt)
    Country Year    growth     ratio
1 Australia 1946 -3.557951 190.41908
2 Australia 1947  2.459475 177.32137
3 Australia 1948  6.437534 148.92981
4 Australia 1949  6.611994 125.82870
5 Australia 1950  6.920201 109.80940
6 Australia 1951  4.272612  87.09448

Now add panel design variables to quickly create a psData panel object:

> as.panel(debt, "Country", "Year")
 Panel data frame [ 1171 rows x  4 columns, 20 Country x 64 Year ]

    Country Year    growth     ratio
1 Australia 1946 -3.557951 190.41908
2 Australia 1947  2.459475 177.32137
3 Australia 1948  6.437534 148.92981
4 Australia 1949  6.611994 125.82870
5 Australia 1950  6.920201 109.80940
6 Australia 1951  4.272612  87.09448

The object is now a data.frame to which the package can pass functions similar to the xt and ts commands in Stata. Country codes and basic date formats are automatically detected and usable for safe merges between multiple panel data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions