title: How do you parse out output in R and read files in R package
body: <p>I have this function to read data from .csv file and output the result as json format:</p>
  
  <p>My vcenter.csv file looks like this:</p>
  
  <pre><code>Host       Time    Cpu
  server1 1406284200 0.0920
  server1 1406286000 0.0920
  server1 1406287800 0.0912
  server1 1406289600 0.0928
  server1 1406291400 0.0912
  server1 1406293200 0.0904
  
  output&lt;-function(myname){
    library(rjson)
  res&lt;-read.csv("vcenter.csv", header=T, sep=',')
  
  servers &lt;- split(res, res$Host)
  dumFun &lt;- function(x){
    sData &lt;- servers[x][[1]]
    if(nrow(sData) &gt;0){
      # create appropriate list
      dumList &lt;- unname(apply(sData[,2:3], 1, function(y) unname(as.list(y))))
      return(toJSON(list(name = x, data = dumList))) 
    }
  }       
  jsData &lt;- lapply(names(servers), dumFun)
  jsInd &lt;- sapply(jsData, is.null)
  
  p&lt;-paste(jsData[!jsInd], collapse = ',')
  p&lt;-paste('[', p, ']')
  print(p)
  }
  </code></pre>
  
  <p>a. When I call this function remotely I get something like this:</p>
  
  <pre><code>[1] "[ {\"name\":\"server1\",\"data\":[[1406284200,0.387200012]
  </code></pre>
  
  <p>Is it possible to not display [1] and \ values in the output?</p>
  
  <p>b.When I build this code with RStudio as a package with vcenter.csv file and install the package, when I run the output.R function, it does not see the vcenter.csv file. Where should I put the vcenter.csv? I tried putting it in the library directory, the same directory as the output.r script, not luck. I keep getting file(file, "rt") connection error. Any ideas?</p>