[R] adding class attributes to strings: works in a loop, but not directly

2013-05-29 Thread Franckx Laurent
Dear all I try to assign class attributes to strings. Depending on the approach I use, it works (including method dispatch) or fails. Let me clarify with an example. Let: AONtptmodelist - c(FOOT,BICY) When I assign class attributes directly to these strings, it fails: class(BICY) -

Re: [R] adding class attributes to strings: works in a loop, but not directly

2013-05-29 Thread Blaser Nello
There are two separate issues that seem to be unclear. Concerning the class assignment: You cannot assign a class to a character string. You can assign a class to an object that contains a character string: a - b # ok class(a) - AONmode # not ok class(b) - AONmode Error in class(b) - AONmode

Re: [R] adding class attributes to strings: works in a loop, but not directly

2013-05-29 Thread Jeff Newmiller
a) You cannot assign attributes to literal values such as BICY. You must assign them to variables, as in x - BICY class(x) - AONmode b) You cannot give the separate elements of a vector their own separate attributes unless the vector is of mode list. Ordinarily, attributes apply to the whole

Re: [R] adding class attributes to strings: works in a loop, but not directly

2013-05-29 Thread Franckx Laurent
Dear Nello Thanks for the clarification. It was of course an elementary mistake to assume that the for loop would modify the original AONtptmodelist. I also understand now that the issues was that I cannot attribute a class to a literal. Your proposed alternative seems to work now, including the