jeudi 3 septembre 2020

Object modification only happens in list

I have put objects that I would like to edit in a list. I edited the object in the list like this:

for (i in 1:NROW(listbF_P)){
  listbF_P[[i]]@first.year <- 1986
  listbF_P[[i]]@last.year <- 2005
  listbF_P[[i]]@year.aggregate.method <- "mean"
  listbF_P[[i]]@id <- makeFieldID(listbF_P[[i]])
}

When I check whether the changes were successfully applied, it works but only when referring to the objects inside the list but not the same objects "unlisted".

So if I call

listbF_P[[1]]@last.year

it returns

"2005"

But if I call

OBJECT1@last.year

it returns

"Inf"

The problem with this is that I want the edited objects in a different list later. So I need either a way that the latter call example returns "2005" or a way that I can search for a certain object name pattern in multiple lists to put the ones that fit the pattern into another list. This is because the example above was made with multiple lists (listbF_P, listbF_F1, listbF_F2) and these lists contain a pattern matching "X" and another matching "Y". So basically I want to have two lists with edited objects, one matching pattern "X" and the other matching pattern "Y".

I hope my problem and the two possible ways of solving them are clear.. If something isn't, ask :)

Thanks for any input

Regards

Aucun commentaire:

Enregistrer un commentaire