title: How to map values in sublist of list in r
body: <p>Im fairly new to R. I'm trying to apply a function to a value in a sublist that I got, but I don't know where to look.</p>
  
  <p>I read some json files in R like so:</p>
  
  <pre class="lang-r prettyprint-override"><code>library("rjson")
  fileNames &lt;- list.files(path = "/&lt;PATH&gt;/TimedSentences", full.names = TRUE)
  parseJson &lt;- function(fileName){
    fromJSON(file = fileName)
  }
  
  jsons &lt;- lapply(fileNames, parseJson)
  
  jsonToSentJson &lt;- function(jsonList){
    #change sentences to sentiments
  }
  </code></pre>
  
  <p>The json files look a little like this</p>
  
  <pre><code>{
    "name": "&lt;STORYNAME&gt;",
    "sentences": [
      {
        "beginTime": 880,
        "endTime": 16960,
        "sentence": "Okay, guys, here we go."
      },
      {
        "beginTime": 14160,
        "endTime": 16960,
        "sentence": "Here we go."
      },...]
  }
  </code></pre>
  
  <p>Now I want to get almost the same list back, except that I want to run a function against each sentence value and change it into a sentiment value. I got a package installed that has a function called "get_sentiment" and I basically write a json file that looks a little like this:</p>
  
  <pre><code>{
    "name": "&lt;MOVIENAME&gt;",
    "sentences": [
      {
        "beginTime": 880,
        "endTime": 16960,
        "sentiment": 1.5
      },
      {
        "beginTime": 14160,
        "endTime": 16960,
        "sentiment": 0.0
      },...]
  }
  </code></pre>
  
  <p>What should I look for when I'm trying to do this?</p>
  
  <p>NB: I can figure out how to write the jsn file I think, but I'm having trouble figuring out how to change the value in the sublist</p>