Converting wide tables into long tables

In order to keep only the Region and Name column and convert everything else into a key-value pair, run:

gathered <- gather(tstate, "Keys", "Values", -Region, -Name) %>% arrange(Region) # Note that arrange has been used only for aesthetic purposes 
 
gathered 
 
# # A tibble: 400 x 4 
# Region          Name       Keys Values 
# <fctr>         <chr>      <chr>  <dbl> 
#   1 Northeast   Connecticut Population   3100 
# 2 Northeast         Maine Population   1058 
# 3 Northeast Massachusetts Population   5814 
# 4 Northeast New Hampshire Population    812 
# 5 Northeast    New Jersey Population   7333 
 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.14.245