And change Long/Wide to lowercase to reflect that they are both variables names and a description of the state of the data.pull/18/merge
| id_string <- paste0(", ", paste(sprintf("-%s", ids), collapse = ", ")) | id_string <- paste0(", ", paste(sprintf("-%s", ids), collapse = ", ")) | ||||
| sequence <- c( | sequence <- c( | ||||
| current_state = "Wide", | |||||
| final_state = "Long", | |||||
| current_state = "wide", | |||||
| final_state = "long", | |||||
| operation = sprintf("gather(%s, %s, %s%s)", | operation = sprintf("gather(%s, %s, %s%s)", | ||||
| wname, | wname, | ||||
| dput_parser(key), | dput_parser(key), | ||||
| id_string <- paste0(", ", paste(sprintf("-%s", ids), collapse = ", ")) | id_string <- paste0(", ", paste(sprintf("-%s", ids), collapse = ", ")) | ||||
| sequence <- c( | sequence <- c( | ||||
| current_state = "Long", | |||||
| final_state = "Wide", | |||||
| current_state = "long", | |||||
| final_state = "wide", | |||||
| operation = sprintf("spread(%s, %s, %s)", | operation = sprintf("spread(%s, %s, %s)", | ||||
| lname, | lname, | ||||
| dput_parser(key), | dput_parser(key), |
| > Gather takes multiple columns and collapses into key-value pairs, duplicating all other columns as needed. You use gather() when you notice that your column names are not names of variables, but values of a variable. | > Gather takes multiple columns and collapses into key-value pairs, duplicating all other columns as needed. You use gather() when you notice that your column names are not names of variables, but values of a variable. | ||||
| ```{r gather} | ```{r gather} | ||||
| set_font_size(4.5, 15) | |||||
| animate_gather(wide, key = "person", value = "sales", -year) | animate_gather(wide, key = "person", value = "sales", -year) | ||||
| ``` | ``` | ||||
| > of a variable. | > of a variable. | ||||
| ``` r | ``` r | ||||
| set_font_size(4.5, 15) | |||||
| animate_gather(wide, key = "person", value = "sales", -year) | animate_gather(wide, key = "person", value = "sales", -year) | ||||
| ``` | ``` | ||||