0

I have a question.

For example, I would like to remove a dataframe, df_to_remove, in R.

I can remove it in this way: rm("df_to_remove").

If I set a string variable called dataframe_name. dataframe_name = "df_t_remove"

Why the following commend does not work? rm(eval(dataframe_name))?

How to remove a dataframe in R by a string variable?

Pdubbs
  • 1,967
  • 2
  • 11
  • 20
L. J.
  • 1
  • You shouldn't need to do this often. If you are, it may be time to learn about [lists of data frames](https://stackoverflow.com/a/24376207/4497050) and [list columns](https://github.com/cwickham/purrr-tutorial). – alistaire Mar 08 '18 at 19:04

1 Answers1

1

Use the list = argument in rm():

x <- 5
y <- 'x'
rm(list = y)
divibisan
  • 11,659
  • 11
  • 40
  • 58