I'm trying to figure out how can I add something to a data frame df
, based on a variable (i.e. a date), ending up with a data frame named df_17
if variable is equal to 2017 for example.
The reason why I want this is because I'm importing datasets from several years and quarters, and I would like to make sure that they are named according to the year variable they have. Each dataset only has 1 date. I know I can do it manually but it would take me less time to automate it.
I know how to do it with columns and rows, but I can't figure it out for objects.
EDIT:
Example 1: Data frame name "df"
A B Date
1 4 2017
2 3 2017
New data frame name "df_2017"
Example 2: Data frame name "df"
A B Date
1 4 2016
2 3 2016
New data frame name - "df_2016 "