Using melt and dcast in data.table

Scott Prevost

2019/03/23

melt(data,
     id.vars = c("will_not_change")                      # Columns will remain the same, constant identifiers that all variables have associated values for
     measure.vars = c("converted_to_variable_value"))    # Columns names go into `variable` column and values go into `values` columns
     

# Optional -> specify column names

melt(data,
     id.vars = c("will_not_change")
     measure.vars = c("converted_to_variable_value"),
     variable.name = "name_of_variable_column",
     value.name = "name_of_value_column")