Learn R Programming

statar (version 0.5.0)

is.panel: Check whether a data.frame is a panel

Description

Check whether a data.frame is a panel

Usage

is.panel(df, ...)

is.panel_(df, vars)

Arguments

df
a data frame
...
a list of variables. All except last are the id variable. Last is time variable
vars
Used to work around non standard evaluation

Value

  • The function is.panel check that there are no duplicate combinations of the variables in ... and that no observation is missing for the last variable in ... (the time variable).

Examples

Run this code
library(dplyr)
df <- data_frame(
    id1    = c(1, 1, 1, 2, 2),
    id2   = 1:5,
    year  = c(1991, 1993, NA, 1992, 1992),
    value = c(4.1, 4.5, 3.3, 3.2, 5.2)
)
is.panel(df, id1, year)
df <- df %>% filter(!is.na(year))
is.panel(df, id1, year)
is.panel(df, id1, id2, year)

Run the code above in your browser using DataLab