title: separate a column into multiple variables with unique column names in R
body: <p>Here is how I want my dataframe to look: </p>
  
  <pre><code>record    color    size    height    weight
  1         blue     large             heavy
  1         red                        
  2         green    small   tall      thin
  </code></pre>
  
  <p>However, the data (df) appears as follows: </p>
  
  <pre><code>record    vars
  1         color = "blue", size = "large"
  2         color = "green", size = "small"
  2         height = "tall", weight = "thin"
  1         color = "red", weight = "heavy"
  </code></pre>
  
  <p>The code for df</p>
  
  <pre><code>structure(list(record = c(1L, 2L, 2L, 1L), vars = structure(c(1L, 
                                                                2L, 4L, 
  3L), .Label = c("color = \"blue\", size = \"large\"", 
  
  "color = \"green\", size = \"small\"", "color = \"red\", weight = 
  \"heavy\"", 
  
  "height = \"tall\", weight = \"thin\""), class = "factor")), class = 
  "data.frame", row.names = c(NA, 
  
  -4L))
  </code></pre>
  
  <p>For each record, I would like to separate the vars column by the "," delimiter, and create a new column with the indicated variable name...The record should be repeated if there are multiple values for a particular variable</p>
  
  <p>I know that to do this with tidyverse I will need to use dplyr::group_by and dplyr::separate, however I'm not clear how to incorporate the new variable names in the "into" parameter for separate. Do I need some type of regular expression to identify any text prior to an equal sign "=" as the new variable name in "into"?? Any suggestions much welcome!</p>
  
  <pre><code>df %&gt;%
    group_by(record) %&gt;%
    separate(col = vars, into = c(regex expression?? / character vector?), sep = ",")
  </code></pre>