Question from an R noob
I have some code I apply to a variable set of data, which may or may not contain data I am looking for. As such, my code generates an incomplete set of objects, which I then combine into an overall object.
obj1<-c(1,2,3)
obj2<-c(4,5,6)
MyList<-list(Obj1,Obj2,Obj3)
Error: object 'Obj3' not found
Because the data I am looking for is not always present, I sometimes generate null objects, which I have to manually remove from my list, when I try to combine all objects into a list:
MyList<-list(Obj1,Obj2)
How do I automate the check on objects, before adding them to the overall list to ensure only objects that actually exist are added to the List? I assume I need the 'if' and 'exists' function, but I cant quite work out how to combine them with the 'List' function
Aucun commentaire:
Enregistrer un commentaire