I have a global environment of over 30 dataframes that will get even more filled as I write more. I needed to create separate dataframes for observations with data in each variable (almost as if they were separate groups). Hence why it is so large.
The dataframes all have the same data and column names:
ID VOne VTwo VThree VFour
123 2 1 1 1
101 3 1 1 1
ID VOne VTwo VThree VFour
140 1 3 1 1
112 1 3 1 1
115 1 2 1 1
As you can see, the only thing that differs is the variable with data larger than 1 and the number of observations. Is there a way to condense the dataframes into a larger set I can choose from so I can remove the dataframes from the global environment so that they don't bog it up?
I tried:
df_master_list <- list(df1, df2)
But it isn't easy to discern which dataframe is which (in my actual data, I have over 30 all with specific names). Can I rename the items in the list easily in one or two steps without creating a vector of over 30 names and setNames
?
I am trying to find a way to rename the items in a list (or create a named list) without creating a list of 30 or more names. That is to say, I section in a list that say name should say the dataframe's name (like df1 or df2) instead of the default 1, 2, and so on.