Description Usage Arguments Value Author(s) References Examples
View source: R/ff_panel_expand.R
There is a variable recorded for a panel, and a variable with date info, and another with obs info Compute averages over sub-groups of dates for each variable, with different ways of specifying date subgroups. average(svr_data) over svr Reshape data so each date is a variable for selected subset of key variables Merge results from 2 back to main, so that each indi/date observation has as variables all lagged and forward information as additional variables. Append not n lag m forward, but full history as additional variables Doing this allows for lagged intereaction that are time specific in an arbitrary way.
1 | ff_panel_expand_longandwide(df, svr_id_t, svr_id_i, svr_data)
|
svr_id_t |
string time variable name |
svr_id_i |
string individual ID name |
svr_data |
string variable name |
a long panel frame with wide expansion of group mean lagged vars
Fan Wang, http://fanwangecon.github.io
https://fanwangecon.github.io/REconTools/reference/ff_panel_expand_longandwide.html https://fanwangecon.github.io/REconTools/articles/fv_panel_expand_longandwide.html https://github.com/FanWangEcon/REconTools/blob/master/R/ff_panel_expand.R
1 2 3 4 5 6 7 8 9 10 11 12 | library(dplyr)
df_hw_cebu <- df_hgt_wgt %>% filter(S.country == 'Cebu' & svymthRound <= 24 & svymthRound > 0)
df_hw_cebu <- df_hw_cebu %>% mutate(mth6 = recode(svymthRound,
`0`="m00t06", `2`="m00t06", `4`="m00t06", `6`="m00t06",
`8`="m08t12", `10`="m08t12", `12`="m08t12",
`14`="m14t18", `16`="m14t18", `18`="m14t18",
`20`="m20t24", `22`="m20t24", `24`="m20t24"))
df_longandwide <- ff_panel_expand_longandwide(df_hw_cebu,
svr_id_t = 'mth6',
svr_id_i = 'indi.id',
svr_data = 'cal')
print(df_longandwide %>% select(indi.id, svymthRound, mth6, cal, matches('mth6'), everything()), n=100)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.