R cookbook
fct_relevel
按照因子level重排序比如给面板数据的id
cul <- read_csv("../data/cul.csv")
pdata <- read_csv("../data/data_gao.csv")
pdata <- pdata %>% pdata.frame(index = c("id", "time")) %>% filter(!id %in% c("GB","ZA"))
pdata <-
pdata %>%
mutate(id = fct_relevel(id, cul$ctr_left)) %>% #按照cul$ctr_left的顺序重新排列id
arrange(time, id)