I have a data frame that is formatted like this:
| details | col_1 | col2 | col3 |
|---|---|---|---|
| ex1 2019 test | 1 | 1 | 1 |
| ex1 2020 review | 2 | 2 | 2 |
| example2 2021 survey | 3 | 3 | 3 |
| row3 2019 data | 4 | 4 | 4 |
I want to create a new column called "Year" appended to the end of this data frame that takes the year value from the row name. I want it to look like this:
| details | col_1 | col2 | col3 | Year |
|---|---|---|---|---|
| ex1 2019 test | 1 | 1 | 1 | 2019 |
| ex1 2020 review | 2 | 2 | 2 | 2020 |
| example2 2021 survey | 3 | 3 | 3 | 2021 |
| row3 2019 data | 4 | 4 | 4 | 2019 |
The row names are unstandardized on purpose to reflect my actual data. Thanks in advance for the help!