title: How do i transform a factor with comma seperated values to a numeric vector in R?
body: <p>I import my data from a json file and i need some of the elements as numeric values.</p>
  <p>the json:</p>
  <pre><code>[
    {
      &quot;a&quot;: 52,
      &quot;b&quot;: 2020,
      &quot;c&quot;: 14,
      &quot;d&quot;: &quot;1,2,3,4,5,6,7,8,9&quot;,
      &quot;e&quot;: &quot;4,1,2,3,1,0,0,0,0&quot;,
      &quot;f&quot;: &quot;TRUE&quot;
    }
  ]
  </code></pre>
  <p>the code for the import:</p>
  <pre><code>json_file &lt;- fromJSON(file = &quot;file&quot;)
  
  json_file &lt;- lapply(json_file, function(x) {
    x[sapply(x, is.null)] &lt;- NA
    unlist(x)
  })
  
  json_file &lt;-as.data.frame(do.call(&quot;rbind&quot;, json_file))
  </code></pre>
  <p>Now what i am trying to do is get the values out of d and transform them to a numeric vector:</p>
  <pre><code>d_numeric &lt;- as.numeric(json_file$d)
  </code></pre>
  <p>The error which occurs is &quot;NAs introduced by coercion&quot; and the issue seems to be that the single values out of d are seen as one level because of the commas (str below). How may I seperate them?</p>
  <pre><code>str(json_file$d)
   Factor w/ 1 level &quot;1,2,3,4,5,6,7,8,9&quot;: 1
   - attr(*, &quot;names&quot;)= chr &quot;Woche&quot;
  </code></pre>
  <p>Best regards
  tholori</p>