Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S4 development branch #7

Open
briatte opened this issue Mar 5, 2014 · 8 comments
Open

S4 development branch #7

briatte opened this issue Mar 5, 2014 · 8 comments

Comments

@briatte
Copy link
Contributor

briatte commented Mar 5, 2014

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.

@christophergandrud
Copy link
Contributor

Excellent work. Sorry I've been a bit remiss lately because of other projects.

However, I just added the work you did into a new branch to the main rOpenGov/psData repo. It's called devPanel.

If it's ok with you, I think we should focus development around this branch.

@christophergandrud
Copy link
Contributor

Your listed as collaborator on the repo so you should be able to push and pull freely. Let me know if you have any issues.

@christophergandrud
Copy link
Contributor

One more thing. I added the email address listed on your website to the .travis.yml. So you'll get updates of whether or not each commit passes. Let me know if you don't want this and we could just take it out.

@briatte
Copy link
Contributor Author

briatte commented Mar 6, 2014

@christophergandrud I'm good with all suggestions, will continue development at end of March (writing up before that).

@jrnold
Copy link

jrnold commented Mar 7, 2014

Thanks. I'll have to take a closer look at this when I have some time. I'm
curious about the ropengov project.

Sorry that I didn't notice that you were using dataframeconstr earlier. You
should look at my package checker. It is the continuation of the package;
though I'd have to remind myself of what I changed and updated in the code.

Jeff

I'm good with all suggestions, will continue development at end of March
(writing up before that).

Reply to this email directly or view it on GitHub.

@briatte
Copy link
Contributor Author

briatte commented Mar 7, 2014

@jrnold don't worry about timing, I forked your repo just a few days ago :)

It's likely that my hack of your class can be improved in many ways. Please feel free to point inadequacies, there are many, as I am new to S4 classes overall.

@jrnold
Copy link

jrnold commented Mar 16, 2014

Thanks. Again sorry for my delay. What I was saying is that you should look
at my package https://github.com/jrnold/r-checker. It is an updated version
of dataframeconstr; I should have probably removed this package. I'd need
to look back over my code to remind myself what changed, but I must have
improved some things.

Jeff

@jrnold https://github.com/jrnold don't worry about timing, I forked your
repo just a few days ago :)

It's likely that my hack of your class can be improved in many ways. Please
feel free to point inadequacies, there are many, as I am new to S4 classes
overall.

Reply to this email directly or view it on
GitHubhttps://github.com//issues/7#issuecomment-37060114
.

@briatte
Copy link
Contributor Author

briatte commented Mar 16, 2014

@jrnold thanks for the details — I'll update psData to that version of your S4 class next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants