title: How to change all the unique values of a variable in dataframe R
body: <p>I will appreciate any help with this. I think it should be simple, but I haven't found any solution in Internet. I have the following sample dataframe</p>
  <pre><code>ddd &lt;- structure(list(code = structure(c(174L, 174L, 174L, 174L, 174L, 
  174L, 204L, 204L, 204L, 204L, 204L, 204L), .Label = c(&quot;ABW&quot;, 
  &quot;AFG&quot;, &quot;AGO&quot;, &quot;ALB&quot;, &quot;AND&quot;, &quot;ARB&quot;, &quot;ARE&quot;, &quot;ARG&quot;, &quot;ARM&quot;, &quot;ASM&quot;, 
  &quot;ATG&quot;, &quot;AUS&quot;, &quot;AUT&quot;, &quot;AZE&quot;, &quot;BDI&quot;, &quot;BEL&quot;, &quot;BEN&quot;, &quot;BFA&quot;, &quot;BGD&quot;, 
  &quot;BGR&quot;, &quot;BHR&quot;, &quot;BHS&quot;, &quot;BIH&quot;, &quot;BLR&quot;, &quot;BLZ&quot;, &quot;BMU&quot;, &quot;BOL&quot;, &quot;BRA&quot;, 
  &quot;BRB&quot;, &quot;BRN&quot;, &quot;BTN&quot;, &quot;BWA&quot;, &quot;CAF&quot;, &quot;CAN&quot;, &quot;CEB&quot;, &quot;CHE&quot;, &quot;CHI&quot;, 
  &quot;CHL&quot;, &quot;CHN&quot;, &quot;CIV&quot;, &quot;CMR&quot;, &quot;COD&quot;, &quot;COG&quot;, &quot;COL&quot;, &quot;COM&quot;, &quot;CPV&quot;, 
  &quot;CRI&quot;, &quot;CSS&quot;, &quot;CUB&quot;, &quot;CUW&quot;, &quot;CYM&quot;, &quot;CYP&quot;, &quot;CZE&quot;, &quot;DEU&quot;, &quot;DJI&quot;, 
  &quot;DMA&quot;, &quot;DNK&quot;, &quot;DOM&quot;, &quot;DZA&quot;, &quot;EAP&quot;, &quot;EAR&quot;, &quot;EAS&quot;, &quot;ECA&quot;, &quot;ECS&quot;, 
  &quot;ECU&quot;, &quot;EGY&quot;, &quot;EMU&quot;, &quot;ERI&quot;, &quot;ESP&quot;, &quot;EST&quot;, &quot;ETH&quot;, &quot;EUU&quot;, &quot;FCS&quot;, 
  &quot;FIN&quot;, &quot;FJI&quot;, &quot;FRA&quot;, &quot;FRO&quot;, &quot;FSM&quot;, &quot;GAB&quot;, &quot;GBR&quot;, &quot;GEO&quot;, &quot;GHA&quot;, 
  &quot;GIB&quot;, &quot;GIN&quot;, &quot;GMB&quot;, &quot;GNB&quot;, &quot;GNQ&quot;, &quot;GRC&quot;, &quot;GRD&quot;, &quot;GRL&quot;, &quot;GTM&quot;, 
  &quot;GUM&quot;, &quot;GUY&quot;, &quot;HIC&quot;, &quot;HKG&quot;, &quot;HND&quot;, &quot;HPC&quot;, &quot;HRV&quot;, &quot;HTI&quot;, &quot;HUN&quot;, 
  &quot;IBD&quot;, &quot;IBT&quot;, &quot;IDA&quot;, &quot;IDB&quot;, &quot;IDN&quot;, &quot;IDX&quot;, &quot;IMN&quot;, &quot;IND&quot;, &quot;INX&quot;, 
  &quot;IRL&quot;, &quot;IRN&quot;, &quot;IRQ&quot;, &quot;ISL&quot;, &quot;ISR&quot;, &quot;ITA&quot;, &quot;JAM&quot;, &quot;JOR&quot;, &quot;JPN&quot;, 
  &quot;KAZ&quot;, &quot;KEN&quot;, &quot;KGZ&quot;, &quot;KHM&quot;, &quot;KIR&quot;, &quot;KNA&quot;, &quot;KOR&quot;, &quot;KWT&quot;, &quot;LAC&quot;, 
  &quot;LAO&quot;, &quot;LBN&quot;, &quot;LBR&quot;, &quot;LBY&quot;, &quot;LCA&quot;, &quot;LCN&quot;, &quot;LDC&quot;, &quot;LIC&quot;, &quot;LIE&quot;, 
  &quot;LKA&quot;, &quot;LMC&quot;, &quot;LMY&quot;, &quot;LSO&quot;, &quot;LTE&quot;, &quot;LTU&quot;, &quot;LUX&quot;, &quot;LVA&quot;, &quot;MAC&quot;, 
  &quot;MAF&quot;, &quot;MAR&quot;, &quot;MCO&quot;, &quot;MDA&quot;, &quot;MDG&quot;, &quot;MDV&quot;, &quot;MEA&quot;, &quot;MEX&quot;, &quot;MHL&quot;, 
  &quot;MIC&quot;, &quot;MKD&quot;, &quot;MLI&quot;, &quot;MLT&quot;, &quot;MMR&quot;, &quot;MNA&quot;, &quot;MNE&quot;, &quot;MNG&quot;, &quot;MNP&quot;, 
  &quot;MOZ&quot;, &quot;MRT&quot;, &quot;MUS&quot;, &quot;MWI&quot;, &quot;MYS&quot;, &quot;NAC&quot;, &quot;NAM&quot;, &quot;NCL&quot;, &quot;NER&quot;, 
  &quot;NGA&quot;, &quot;NIC&quot;, &quot;NLD&quot;, &quot;NOR&quot;, &quot;NPL&quot;, &quot;NRU&quot;, &quot;NZL&quot;, &quot;OED&quot;, &quot;OMN&quot;, 
  &quot;OSS&quot;, &quot;PAK&quot;, &quot;PAN&quot;, &quot;PER&quot;, &quot;PHL&quot;, &quot;PLW&quot;, &quot;PNG&quot;, &quot;POL&quot;, &quot;PRE&quot;, 
  &quot;PRI&quot;, &quot;PRK&quot;, &quot;PRT&quot;, &quot;PRY&quot;, &quot;PSE&quot;, &quot;PSS&quot;, &quot;PST&quot;, &quot;PYF&quot;, &quot;QAT&quot;, 
  &quot;ROU&quot;, &quot;RUS&quot;, &quot;RWA&quot;, &quot;SAS&quot;, &quot;SAU&quot;, &quot;SDN&quot;, &quot;SEN&quot;, &quot;SGP&quot;, &quot;SLB&quot;, 
  &quot;SLE&quot;, &quot;SLV&quot;, &quot;SMR&quot;, &quot;SOM&quot;, &quot;SRB&quot;, &quot;SSA&quot;, &quot;SSD&quot;, &quot;SSF&quot;, &quot;SST&quot;, 
  &quot;STP&quot;, &quot;SUR&quot;, &quot;SVK&quot;, &quot;SVN&quot;, &quot;SWE&quot;, &quot;SWZ&quot;, &quot;SXM&quot;, &quot;SYC&quot;, &quot;SYR&quot;, 
  &quot;TCA&quot;, &quot;TCD&quot;, &quot;TEA&quot;, &quot;TEC&quot;, &quot;TGO&quot;, &quot;THA&quot;, &quot;TJK&quot;, &quot;TKM&quot;, &quot;TLA&quot;, 
  &quot;TLS&quot;, &quot;TMN&quot;, &quot;TON&quot;, &quot;TSA&quot;, &quot;TSS&quot;, &quot;TTO&quot;, &quot;TUN&quot;, &quot;TUR&quot;, &quot;TUV&quot;, 
  &quot;TZA&quot;, &quot;UGA&quot;, &quot;UKR&quot;, &quot;UMC&quot;, &quot;URY&quot;, &quot;USA&quot;, &quot;UZB&quot;, &quot;VCT&quot;, &quot;VEN&quot;, 
  &quot;VGB&quot;, &quot;VIR&quot;, &quot;VNM&quot;, &quot;VUT&quot;, &quot;WLD&quot;, &quot;WSM&quot;, &quot;XKX&quot;, &quot;YEM&quot;, &quot;ZAF&quot;, 
  &quot;ZMB&quot;, &quot;ZWE&quot;), class = &quot;factor&quot;), year = c(&quot;1960&quot;, &quot;1961&quot;, &quot;1962&quot;, 
  &quot;1963&quot;, &quot;1964&quot;, &quot;1965&quot;, &quot;1960&quot;, &quot;1961&quot;, &quot;1962&quot;, &quot;1963&quot;, &quot;1964&quot;, 
  &quot;1965&quot;), gdp = c(0.148355493351994, 0.167249825052484, 0.172848145556333, 
  0.179146256123163, 0.175647305808257, 0.186144156752974, 0.0832750174947515, 
  0.0944716585024493, 0.100069979006298, 0.0965710286913926, 0.115465360391882, 
  0.118964310706788)), row.names = c(NA, -12L), class = c(&quot;tbl_df&quot;, 
  &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>
  <p>I want to replace all unique values in the variable year (from 1960 to 1965) by other values, lets say by 1961 to 1966. In other words, I want to replace all 1960s in the current dataframe by 1961s, all 1961s in the current dataframe by 1962s and so on. Of course, this is a sample and here this can be done one by one (I found how to do this in Internet). However, the dataframe I have has 200 unique values for the variable &quot;code&quot; and 70 years for the variable &quot;year&quot;. So, it is unmanageable to do the change one by one.</p>
  <p>Very much thank you in advance</p>