Load a dataset into R with data() using a variable instead of the dataset name
I am trying to load a dataset into R using the data() function. It works fine when I use the dataset name (e.g. data(Titanic) or data("Titanic") ). What doesn't work for me is loading a dataset using a variable instead of its name. For example: # This works fine: > data(Titanic) # This works fine as well: > data("Titanic") # This doesn't work: > myvar <- Titanic > data(myvar) **Warning message: In data(myvar) : data set ‘myvar’ not found** Why is R looking for a dataset named "myvar" since it is not quoted? And since this is the default behavior, isn't there a way to load a dataset stored in a