pibble: Create a pibble panel data set object

Description Usage Arguments Details Examples

View source: R/pibble.R

Description

This function declares a pibble tibble with the attributes .i, .t, and .d.

Usage

1
pibble(..., .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE)

Arguments

...

A set of name-value pairs to make up the variables of a pibble.

.i

Quoted or unquoted variable(s) that identify the individual cases. If this is omitted, pibble will assume the data set is a single time series.

.t

Quoted or unquoted variable indicating the time. pmdplyr accepts two kinds of time variables: numeric variables where a fixed distance .d will take you from one observation to the next, or, if .d=0, any standard variable type with an order. Consider using the time_variable() function to create the necessary variable if your data uses a Date variable for time.

.d

Number indicating the gap in t between one period and the next. For example, if .t indicates a single day but data is collected once a week, you might set .d=7. To ignore gap length and assume that "one period ago" is always the most recent prior observation in the data, set .d=0. By default, .d=1.

.uniqcheck

Logical parameter. Set to TRUE to perform a check of whether .i and .t uniquely identify observations, and present a message if not. By default this is set to FALSE and the warning message occurs only once per session.

Details

The pibble() function is for the purpose of creating pibble objects from scratch. You probably want as_pibble.

Note that pibble does not require that .i and .t uniquely identify the observations in your data, but it will give a warning message (a maximum of once per session, unless .uniqcheck=TRUE) if they do not.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Creating a pibble from scratch
pd <- pibble(
  i = c(1, 1, 1, 2, 2, 2),
  t = c(1, 2, 3, 1, 2, 2),
  x = rnorm(6),
  .i = i,
  .t = t
)
is_pibble(pd)
# I set .d=0 here to indicate that I don't care how large the gap between one period and the next is
# If I want to use 'seconds' for t.
# See time_variable() to turn unruly variables into well-behaved integers, as well
pd2 <- pibble(
  i = c(1, 1, 1, 2, 2, 2),
  seconds = c(123, 456, 789, 103, 234, 238),
  .i = i,
  .t = seconds,
  .d = 0
)
is_pibble(pd2)

pmdplyr documentation built on July 2, 2020, 4:08 a.m.