title: Renaming datasets in environment
body: <p>Here's what is in my environment. I have a bunch of csv files loaded as data frames ,named by some combination of Month/Year, in my environment.</p>
  
  <p><a href="https://i.stack.imgur.com/HJb85.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HJb85.jpg" alt="enter image description here"></a></p>
  
  <p>What I would like to do is rename these objects, not the columns/rows, but the objects themselves.</p>
  
  <p>For example, I am interested in removing the "FRL.csv", or last 7 characters of the character string that titles each of these data frames. Then I would get "APR03", "APR04", ..... , "JUL02", "JUL03".</p>
  
  <p><strong>What I've done.</strong></p>
  
  <p>Here's how to acquire the list of names that are the labels of the objects in my environment.</p>
  
  <pre><code>ls(all.names = TRUE, envir = .GlobalEnv)
  
  [1] "APR01FRL.csv" "APR02FRL.csv" "APR03FRL.csv" "APR04FRL.csv" "APR05FRL.csv" "APR06FRL.csv" "APR07FRL.csv"
  [8] "APR08FRL.csv" "APR09FRL.csv" "JAN01FRL.csv" "JAN02FRL.csv" "JAN03FRL.csv" "JAN04FRL.csv" "JAN05FRL.csv"
  [15] "JAN06FRL.csv" "JAN07FRL.csv" "JAN08FRL.csv" "JAN09FRL.csv" "JAN10FRL.csv" "JUL01FRL.csv" "JUL02FRL.csv"
  [22] "JUL03FRL.csv" "JUL04FRL.csv" "JUL05FRL.csv" "JUL06FRL.csv" "JUL07FRL.csv" "JUL08FRL.csv" "JUL09FRL.csv"
  [29] "JUL10FRL.csv" "MAR10FRL.csv" "MAY10FRL.csv" "NOV09FRL.csv" "NOV10FRL.csv" "OCT01FRL.csv" "OCT02FRL.csv"
  [36] "OCT03FRL.csv" "OCT04FRL.csv" "OCT05FRL.csv" "OCT06FRL.csv" "OCT07FRL.csv" "OCT08FRL.csv" "SEP09FRL.csv"
  [43] "SEP10FRL.csv"
  
  
  
  assign(
     ls(all.names = TRUE, envir = .GlobalEnv), 
     paste(
       substr(ls(all.names = TRUE, envir = .GlobalEnv), 1, 3), 
       substr(ls(all.names = TRUE, envir = .GlobalEnv), 4, 5), 
             sep = "-")
     )
  </code></pre>
  
  <p>Which is just me attempting to assign new strings to replace those in the global environment.</p>
  
  <p>Inside the paste code are strings that I am inputting.</p>
  
  <pre><code>paste(
           substr(ls(all.names = TRUE, envir = .GlobalEnv), 1, 3), 
           substr(ls(all.names = TRUE, envir = .GlobalEnv), 4, 5), 
                 sep = "-")
  
  [1] "APR-01" "APR-02" "APR-03" "APR-04" "APR-05" "APR-06" "APR-07" "APR-08" "APR-09" "JAN-01" "JAN-02" "JAN-03"
  [14] "JAN-04" "JAN-05" "JAN-06" "JAN-07" "JAN-08" "JAN-09" "JAN-10" "JUL-01" "JUL-02" "JUL-03" "JUL-04" "JUL-05" "JUL-06"
  [27] "JUL-07" "JUL-08" "JUL-09" "JUL-10" "MAR-10" "MAY-10" "NOV-09" "NOV-10" "OCT-01" "OCT-02" "OCT-03" "OCT-04" "OCT-05"
  [40] "OCT-06" "OCT-07" "OCT-08" "SEP-09" "SEP-10"
  </code></pre>
  
  <p>I get this error when I run the assign code.</p>
  
  <blockquote>
    <p>Warning message: In assign(ls(all.names = TRUE, envir = .GlobalEnv),
    paste(substr(ls(all.names = TRUE,  :   only the first element is used
    as variable name</p>
  </blockquote>
  
  <p>and none of the data sets in my environment are renamed. </p>
  
  <p><a href="https://i.stack.imgur.com/caamW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/caamW.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Does anyone have suggestions on how to go about renaming objects in the environment pane, or the objects themselves?</strong></p>