[R] cant find "get"?

Thomas Lumley thomas at biostat.washington.edu
Fri Sep 1 17:26:07 CEST 2000


On Fri, 1 Sep 2000, Martin Maechler wrote:

> >>>>> "JohnS" == Strumila, John <John.Strumila at team.telstra.com> writes:
> 
> 
>     JohnS> I found this great function called "get" which allows me to work
>     JohnS> out my object name at run time.  Unfortunately it's not letting
>     JohnS> me assign values with it.  What am I doing wrong?
> 
>      >> names(get(file.name))[1]
>      [1] "X14.59.23"
>      >> names(get(file.name))[1] <- "date"
>      Error: couldn't find function "get<-"
> 
> in spite of Thomas' excellent explanation about  `` foo(x) <- .. ''
> I wonder if John does not just need to be told
>   
>      ``	?assign ''

But he wants to do
	names()[1]<-"date"
on this variable, which would 
  a) involve messy paste() commands
and 
  b) not work

R> a<-data.frame(x=1:4,y=1:4)
R> assign("names(a)[1]","foo")
R> names(a)
[1] "x" "y"


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list