ff_spread_dual | R Documentation |
The 'spread' function only takes one value column. But, we often need to spread a dataset into wide-form, but with two value columns. A example is when we want to spread a dataset, but keep the estimate and standard error columns. This function allows users to spread a dataset and keep two value columns.
ff_spread_dual(df, key, value_a, value_b, join_cols)
df |
Dataframe of ACS data |
key |
Key column in dataframe as string (the column with the information we want to spread on) |
value_a |
First value column we want to keep as string |
value_b |
Second value column we want to keep as string |
join_cols |
Each value column is spread individually, and then both new spread datasets are joined. 'join_cols' signifies which column to join the to datasets on. |
A dataframe with seperate columns for each of the values spread on, and value_a and value_b. The final dataframe will contain all the join columns and value columns totaling the number of items to spread on times two (two different values that are kept when spreading).
ff_spread_dual(total, 'description', 'estimate', 'se', c('geo_description', 'year'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.