title: Writing an array in JSON object in R
body: <p>I have a dataframe where there are multiple cities. I need a separate json object for each state.</p>
  
  <p>so the observation looks like the following:</p>
  
  <pre><code>name         country    state
  Lake Forest             VT, CA, IL, NJ, NC
  </code></pre>
  
  <p>the object is </p>
  
  <pre><code>"location":[{
  "name": "Lake Forest",
  "state": "VT",
  "country": ""},{
  "name": "Lake Forest",
  "state": "CA",
  "country": ""},{
  "name": "Lake Forest",
  "state": "IL",
  "country": ""},{
  "name": "Lake Forest",
  "state": "NJ",
  "country": ""},{
  "name": "Lake Forest",
  "state": "NC",
  "country": ""}]
  </code></pre>
  
  <p>some sample data (with the dput) is given below:</p>
  
  <pre><code>structure(list(name = c("Lake Forest", "Yale,UC Berkeley", "Harvard,Emory,the University of Denver,the University of Washington,Vassar College,Lake Forest,Texas Christian University", "MIT,Princeton,Yale,UCLA,NYU,Emory,UC Berkeley,UNC-Chapel Hill,American,the University of Washington,Lake Forest College,the University of Texas at Austin", "Princeton,Yale"), country = c("", "", "", "", ""), state = list(c("VT", "CA", "IL", "NJ", "NC"), character(0), character(0), character(0), c("CA", "CO", "CT", "FL", "GA", "IL", "IN", "MD", "MA", "MI", "MN", "MO", "NV", "NH", "NJ", "NY", "NC", "OH", "OR", "PA", "RI", "TN", "TX", "VA", "WA"))), .Names = c("name", 
  "country", "state"), row.names = c(3265L, 3755L, 3756L, 3757L, 3759L), class = "data.frame")
  </code></pre>