Yes, it works perfect, thanks a lot.
-----Original Message----- From: "Marius 't Hart" [mar...@ai178182.ai.rug.nl] Date: 01/18/2014 04:58 PM To: "ce" <zadi...@excite.com> CC: "" <r-help@r-project.org> Subject: Re: [R] accessing an object with a variable ? Does this help you? http://stackoverflow.com/questions/3971844/access-variable-value-where-the-name-of-variable-is-stored-in-a-string-in-r On Sat, 18 Jan 2014, ce wrote: > > I want access and object , its name is in an variable : > > require(xts) > data(sample_matrix) > > head(sample_matrix) > Open High Low Close > 2007-01-02 50.03978 50.11778 49.95041 50.11778 > 2007-01-03 50.23050 50.42188 50.23050 50.39767 > 2007-01-04 50.42096 50.42096 50.26414 50.33236 > 2007-01-05 50.37347 50.37347 50.22103 50.33459 > 2007-01-06 50.24433 50.24433 50.11121 50.18112 > 2007-01-07 50.13211 50.21561 49.99185 49.99185 >> assign("a",sample_matrix) >> head(a) > > Open High Low Close > 2007-01-02 50.03978 50.11778 49.95041 50.11778 > 2007-01-03 50.23050 50.42188 50.23050 50.39767 > 2007-01-04 50.42096 50.42096 50.26414 50.33236 > 2007-01-05 50.37347 50.37347 50.22103 50.33459 > 2007-01-06 50.24433 50.24433 50.11121 50.18112 > 2007-01-07 50.13211 50.21561 49.99185 49.99185 > > > But following doesn't work: > > b="sample_matrix" > assign("a",b) > >> a > [1] "sample_matrix" > > how I can access sample_matrix data when I have only b variable ? > > ______________________________________________ > R-help@r-project.org 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. > ______________________________________________ R-help@r-project.org 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.