title: How to apply a function to specific dataframes within a list
body: <p>I have several dataframes, which each contain temperature data, that I put into a list (shown below is some mock data):</p>
  <pre><code>df1 &lt;- data.frame(XH_warmed_air_1m = c(60, 70, 80, 90, 100),
                    XH_ambient_air_1m = c(60, 70, 80, 90, 100))
  df2 &lt;- data.frame(XH_warmed_air_1m = c(60, 70, 80, 90, 100),
                    XH_ambient_air_1m = c(60, 70, 80, 90, 100))
  df3 &lt;- data.frame(XH_warmed_air_1m = c(0, 10, 20, 30, 40),
                    XH_ambient_air_1m = c(0, 10, 20, 30, 40))
  
  list &lt;- list(df1=df1, df2=df2, df3=df3)
  </code></pre>
  <p>df1 and df2 in this list contain temperature data in fahrenheit, which needs to be converted to celsius (df3's data is already in celsius). So, I made a function to automatically convert the columns to celsius</p>
  <pre><code>f_to_c &lt;- function(df){
    df[[&quot;XH_warmed_air_1m&quot;]] &lt;- fahrenheit.to.celsius(df[[&quot;XH_warmed_air_1m&quot;]])
    df[[&quot;XH_ambient_air_1m&quot;]] &lt;- fahrenheit.to.celsius(df[[&quot;XH_ambient_air_1m&quot;]])
    return(df)
  }
  </code></pre>
  <p>I can use lapply to apply the function to the entire list, but this messes up df3's data by converting it to celsius when it already was in the first place</p>
  <pre><code>list &lt;- lapply(list, f_to_c)
  </code></pre>
  <p>I would like to apply this function only to the needed dataframes, which I've attempted to do below. However, this results in the error message <code># Error in df[[&quot;XH_warmed_air_1m&quot;]] : subscript out of bounds </code></p>
  <pre><code>list &lt;- lapply(list$df1, f_to_c)
  </code></pre>
  <p>What method could I use to apply this function only to dataframes that contain temperatures in fahrenheit?</p>
  <p>Using R version 3.5.1, Mac OS X 10.13.6</p>