This function coerces a tibble, data.frame, or list to a pibble tibble by adding the .i
, .t
, and .d
attributes to it.
as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...) # S3 method for tbl_df as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...) # S3 method for grouped_df as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...) # S3 method for data.frame as_pibble(x, .i = NULL, .t = NULL, .d = 1, .uniqcheck = FALSE, ...) # S3 method for 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.
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)#>#> [1] TRUE#> origin destination #> "origin" "destination"#> insert_date #> "insert_date"#> [1] 0data(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)#>#> [1] TRUE