The opposite of gather() is spread(), which converts a long table into a wide table by converting the values in the key column into column headers, as shown:
spread_df <- spread(gathered, "Keys", "Values") spread_df # Note that this in essence restores the original look alignment of the table # # A tibble: 50 x 10 # Region Name Area Frost `HS Grad` Illiteracy Income `Life Exp` Murder Population # <fctr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> # 1 Northeast Connecticut 4862 139 56.0 1.1 5348 72.48 3.1 3100 # 2 Northeast Maine 30920 161 54.7 0.7 3694 70.39 2.7 1058 # 3 Northeast Massachusetts 7826 103 58.5 1.1 4755 71.83 3.3 5814 ## unite ## The unite function is used to merge two or more variables unite(tstate, "NewColumn", "Region","Name") %>% select(NewColumn) # # A tibble: 50 x 1 # NewColumn # <chr> # 1 South_Alabama # 2 West_Alaska # 3 West_Arizona # 4 South_Arkansas