title: how to convert data frame to json format in R
body: <p>I have a data frame like this:</p>
  
  <pre><code>dput(y)
  structure(list(Name = c("Logon", "Logon", "Logon", "Logon", "Logon", 
  "Logon", "Logon", "Logon", "Logon", "Logon", "Logon", "Logon", 
  "Logon", "Logon", "Logon", "Logon", "Logon", "Logon", "Logon", 
  "Logon"), MONTH = structure(c(15002, 15033, 15061, 15092, 15122, 
  15153, 15183, 15214, 15245, 15275, 15306, 15336, 15367, 15398, 
  15427, 15458, 15488, 15519, 15549, 15580), class = "Date"), TOTAL = c(284697404L, 
  268944957L, 297847827L, 287150001L, 277779620L, 262275285L, 284271058L, 
  294965702L, 285132804L, 238847338L, 242683830L, 314483537L, 324823553L, 
  322896485L, 329044914L, 318228530L, 324395065L, 324988644L, 335464023L, 
  336269471L)), .Names = c("Name", "MONTH", "TOTAL"), row.names = c(3755L, 
  2875L, 3393L, 13558L, 14278L, 11991L, 12300L, 13040L, 47341L, 
  36813L, 44897L, 46836L, 37038L, 46086L, 37261L, 37445L, 48030L, 
  37486L, 38074L, 38818L), class = "data.frame")
  </code></pre>
  
  <p>I need to convert to this data frame to json format like this:</p>
  
  <pre><code>{"name":"Logon","data":[284697404,268944957,... ]}
  </code></pre>
  
  <p>I have this:</p>
  
  <pre><code>servers &lt;- split(y, y$Name)
  dumFun &lt;- function(x){
    sData &lt;- servers[x][[1]]
    if(nrow(sData) &gt;0){
      # create appropriate list
      dumList &lt;- unname(apply(sData[3], 1, function(y) unname(as.list(y))))
      return(toJSON(list(name = x, data = dumList))) 
    }
  }
  
  jsData &lt;- lapply(names(servers), dumFun)
  </code></pre>
  
  <p>This coverts the data as this:</p>
  
  <pre><code>{"name":"Logon","data":[[284697404],[268944957],[297847827],[287150001],[277779620],[262275285],[284271058],[294965702],[285132804],[238847338],[242683830],[314483537],[324823553],[322896485],[329044914],[318228530],[324395065],[324988644],[335464023],[336269471],[324063033],[349017727],[347193478],[355561387],[373885187],[356774443],[386372600],[387573710],[397346365],[388064866],[397269760],[406584525],[353936952]]}"
  </code></pre>
  
  <p>I need the output to be like this:</p>
  
  <pre><code>{"name":"Logon","data":[284697404,268944957,297847827,287150001],...etc}"
  </code></pre>
  
  <p>any ideas?</p>