Panel Data Wrangling Tools

Leading/lagging a panel, creating dummy variables, taking panel differences, looking for panel autocorrelations, and more. Implemented via a 'data.table' back end.


panelWranglR

Travis buildstatus Lifecycle:stable License: GPLv3 CRANstatus

panelWranglR is a simple package for wrangling panel data.

Installation

You can install the stable version of panelWranglR from CRAN with

install.packages("panelWranglR")

The latest version is also available from github using the devtools package

devtools::install_github("JSzitas/panelWranglR")

Introduction

The goal of panelWranglR is to provide simple functions that take care of common panel data wrangling needs, such as lagging a panel, differencing a panel (including selections of variables from a panel), finding correlations/autocorrelations in a panel, and so on. For a full list of all of the available functionality, please refer to the documentation.

Example

Let’s start by lagging a whole panel of data, using 5 lags.

# example data: 
    X <- matrix(rnorm(800000),8000,100)
    tim <- seq(1:4000)
    geo_AT <- rep(c("AT"), length = 4000)
    geo_NO <- rep(c("NO"), length = 4000)
    both_vec_1 <- cbind(tim,geo_NO)
    both_vec_2 <- cbind(tim,geo_AT)
    both <- rbind(both_vec_1,both_vec_2)
    X <- cbind(both,X)
    colnames(X) <- c("time", "geo", paste("V", 1:100, sep = "")) 

library(panelWranglR)

    panel_lag( data = X, 
               cross.section = "geo",
               time.variable = "time",
               lags = 5 )    
    

Or maybe we want to turn the cross section variable into several dummy variables:

panel_dummify( data = X,
               cross.section = "geo" )

We can do that for the time variable too (though it is not recommended with many time ‘levels’!)

Further functionality follows the same general syntax and usage (and documentation hopefully clears up any misunderstandings.)

Contributing

If you would like to contribute a pull request, please do contribute! All contributions will be considered for acceptance, provided they are justifiable and the code is reasonable, regardless of anything related to the person submitting the pull request. Please keep things civil - there is no need for negativity. Also, please do refrain from adding unnecessary dependencies (Ex: pipe) to the package (such pull requests as would add an unnecessary dependency will be denied/ suspended until the code can be made dependency free).

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("panelWranglR")

1.2.13 by Juraj Szitás, 7 years ago


https://github.com/JSzitas/panelWranglR


Report a bug at https://github.com/JSzitas/panelWranglR/issues


Browse source code at https://github.com/cran/panelWranglR


Authors: Juraj Szitás [aut, cre]


Documentation:   PDF Manual  


GPL-3 license


Imports data.table, Hmisc, caret

Suggests testthat


See at CRAN