[R] Using the object of character data type as the name of the slot
Dear all, I have a character string object: chara [1] The name of first slot and a list object: class( try1) [1] list what I want to do is to use the chara as a slot's name of try1. Of course I could do it like: try1$The name of first slot - matrix(, 3, 4) to create a slot of 3x4 matrix with the name The name of first slot However, I would like to know how could I utilize the object chara , and to use the characters it contains as the name of the slot of try1. I appreciate for any suggesion. Thanks. -- Lam C. Tsoi (Alex) Medical University of South Carolina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using the object of character data type as the name of the slot
On 21/06/2007 4:07 PM, Alex Tsoi wrote: Dear all, I have a character string object: chara [1] The name of first slot and a list object: class( try1) [1] list what I want to do is to use the chara as a slot's name of try1. Of course I could do it like: try1$The name of first slot - matrix(, 3, 4) to create a slot of 3x4 matrix with the name The name of first slot However, I would like to know how could I utilize the object chara , and to use the characters it contains as the name of the slot of try1. You can use slot(try1, chara) - matrix(, 3, 4) as long as the slot name contained in chara really is a slot. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.