Standared inteface to spread
.
Take values from the columns named in the columns
argument and
move them into blocks of rows, placing values in the new column specified by value
and indicating which column each value came from in the new column specified by key
.
spread_se( data, key, value, ..., fill = NA, convert = FALSE, drop = TRUE, sep = NULL )
data | data.frame to take values from. |
---|---|
key | character, name for existing column to get new column names from. |
value | character, name for existing column to take values from. |
... | not used, force later arguments to bind by name. |
fill | passed to spread. |
convert | passed to spread. |
drop | passed to spread. |
sep | passed to spread. |
converted data.
d <- wrapr::build_frame( 'id', 'name_for_new_column' , 'value_to_take' | 1 , 'col1' , 'a' | 1 , 'col2' , '10' | 2 , 'col1' , 'b' | 2 , 'col2' , '20' ) spread_se(d, key = 'name_for_new_column', value = 'value_to_take')#> id col1 col2 #> 1 1 a 10 #> 2 2 b 20