R: use tidyr to clean-up data table with structural missing and redundant data
问题 Still trying to get my hands on tidyr packages. If one has a data set with redundant rows like this: require(dplyr) require(tidyr) data <- data.frame( v1 = c("ID1", NA, "ID2", NA), v2 = c("x", NA, "xx", NA), v3 = c(NA, "z", NA, "zz"), v4 = c(22, 22, 6, 6), v5 = c(5, 5, 9, 9)) %>% tbl_df() > data Source: local data frame [4 x 5] v1 v2 v3 v4 v5 1 ID1 x NA 22 5 2 NA NA z 22 5 3 ID2 xx NA 6 9 4 NA NA zz 6 9 Since the id variables v1 - v3 is split into redundant rows with many NAs (and therefore