0

I would like to create an object from the objects listed in the environment, to use this object in a loop, however, I am not successful.

For example, let's say I have an object in the environment called data, so:

ls()[2]
[1] "date"

To create an object called data2008 from data in the environment, I'm trying to:

assign(sprintf('data%i', 2008),
        subset(ls()[2], `TEST`!=1015
               &`TEST`!=2011
               &`TEST`!=1023
               &`TEST`!=1031))

However, I get:

Error in subset.default(ls()[], 'TEST' != 1015 & 'TEST' != 2011 & : object 'TEST' not found

I'm using sprintf('data%i', 2008) in assign because I need to use this in a loop. How can I proceed? I thank the help of all you.

Nuñes
  • 65
  • 6

0 Answers0