I have multiple dataframes which I created for every category name of a list (category.levels = c("Art","Music",...)
- one dataframe for each category level. The dataframes are called Data_Art, Data_Music
etc.
I now try to access those dataframes while looping in a for loop, and perform a merge for each one of them with some other general dataframe. My problem is that all my trials to get the real variable that is represented by the variable fail... for example I tried the following:
for (cat in category.levels)
{
curr.dataset = eval(parse(text=paste("Data",cat,sep='_')))
merged.data = merge(curr.dataset,other_data,by=c("user_id"))
...
}
I also tried to user get()
but still - in all my trials eventually the curr.dataset
is a string
variable and not the variable that the string represents... (I see in the environment viewer that it is a string, and I get error message for the merge
operation). If I try the same outside the loop everything works fine. Is there a problem with using eval/get
inside a loop?