Description Usage Arguments Details Examples
This function coerces a tibble, data.frame, or list to a pibble tibble by adding the .i
, .t
, and .d
attributes to it.
1 2 3 4 5 6 7 8 9 10 11 12 13 | as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...)
## S3 method for class 'tbl_df'
as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...)
## S3 method for class 'grouped_df'
as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...)
## S3 method for class 'data.frame'
as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...)
## S3 method for class 'list'
as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...)
|
x |
A data frame, tibble or list |
.i |
Quoted or unquoted variable(s) that identify the individual cases. If this is omitted, |
.t |
Quoted or unquoted variable indicating the time. |
.d |
Number indicating the gap in |
.uniqcheck |
Logical parameter. Set to TRUE to perform a check of whether |
... |
Other arguments passed on to individual methods. |
.i
, Quoted or unquoted variable(s) indicating the individual-level panel identifier
.t
, Quoted or unquoted variable indicating the time variable
.d
, a number indicating the gap
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | data(SPrail)
# 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 'insert_date' for .t with a fixed gap between periods,
# I need to transform it into an integer first; see time_variable()
SP <- as_pibble(SPrail,
.i = c(origin, destination),
.t = insert_date,
.d = 0
)
is_pibble(SP)
attr(SP, ".i")
attr(SP, ".t")
attr(SP, ".d")
data(Scorecard)
# Here, year is an integer, so I can use it with .d = 1 to
# indicate that one period is a change of one unit in year
# Conveniently, .d = 1 is the default
Scorecard <- as_pibble(Scorecard, .i = unitid, .t = year)
is_pibble(Scorecard)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.