title: Sort Data by decade in R
body: <p>So I am fairly new to R and I am having a bit of trouble getting the hang of it. What I am trying to do is to sort my data into decades so that I can analyze the mean value for each decade. So far this is what I have tried:</p>
  
  <pre><code> fred$decade = cut(as.numeric(format(fred$DATE, "%Y")),breaks=seq(1940, 2020, 10))
  </code></pre>
  
  <blockquote>
    <p>Error in format.default(structure(as.character(x), names = names(x),
    dim = dim(x),  : 
        invalid 'trim' argument</p>
  </blockquote>
  
  <p>Here is part of the data I am using: I am looking at CPI data since 1948 for every month until 9/1/2016. I want to get the mean CPI of each decade since then:</p>
  
  <pre><code>DATE    CPI
  8/1/49  23.7
  9/1/49  23.75
  10/1/49 23.67
  11/1/49 23.7
  12/1/49 23.61
  1/1/50  23.51
  2/1/50  23.61
  3/1/50  23.64
  4/1/50  23.65
  5/1/50  23.77
  6/1/50  23.88
  7/1/50  24.07
  8/1/50  24.2
  </code></pre>
  
  
  
  <p>When I use this I always get an error message. I cannot seem to figure out what I am doing wrong.  I went through my data to make sure it was fine.  Thanks for your help! </p>