[R] Access and assign list sub-elements using a string such as "l$a$b"

From: Gregory Jefferis <gsxej2_at_cam.ac.uk>
Date: Thu 15 Jun 2006 - 22:27:05 EST

If I have a list I can set a sub-element as follows on the command line:


But what if I have a string containing the name of the sub-element that I want to access?

subel= "people$tom$hair"

get(subel) # returns error
assign(subel,"red") # silent but doesn't change list people

The attempts above using assign/get won't do what I am trying to do [nor according to the help should they]. I would be very grateful for any suggestions. Many thanks,


Gregory Jefferis, PhD                                   and:
Research Fellow    
Department of Zoology                                   St John's College
University of Cambridge                                 Cambridge
Downing Street                                          CB2 1TP
Cambridge, CB2 3EJ 
United Kingdom

Lab Tel: +44 (0)1223 336683                     Office: +44 (0)1223 339899
Lab Fax: +44 (0)1223 336676

http://www.zoo.cam.ac.uk/zoostaff/jefferis.html           gsxej2_at_cam.ac.uk

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Jun 15 23:58:50 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 16 Jun 2006 - 02:12:53 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.