[R] access objects in my environment

arnaud Gaboury arnaud.gaboury at gmail.com
Thu May 13 11:14:19 CEST 2010


Wonderful!!

TY so much for the help.






> -----Original Message-----
> From: Patrizio Frederic [mailto:frederic.patrizio at gmail.com]
> Sent: Thursday, May 13, 2010 10:47 AM
> To: arnaud Gaboury
> Cc: r-help at r-project.org
> Subject: Re: [R] access objects in my environment
> 
> Hi,
> have a look at function 'get'  (and function 'assign' too)
> In your example:
> 
> x <- 1000
> assign(paste('Pos',x,sep=''),rnorm(100))
> Pos1000
> posa <- get(paste(c("Pos",x),collapse=""))
> posa
> 
> hope it's help
> 
> PF
> 
> On Thu, May 13, 2010 at 10:37 AM, arnaud Gaboury
> <arnaud.gaboury at gmail.com> wrote:
> > Dear group,
> >
> > Here are my objects in my environment:
> >
> >> ls()
> > [1] "Pos100415" "Pos100416" "posA"      "pose15"    "pose16"
>  "pose16t"
> > "position"  "trade"     "x"
> >
> > I need to pass the object "Pos100415" to a function. This element is
> a
> > data.frame, obtained through a function: Pos(x)<-myfun(x) with x<-
> 100415 in
> > this example.
> >
> > If I do this :
> >
> >>posA<-paste(c("Pos",100415),collapse="") #I can't use directly
> Pos100415.I
> > need to access it via paste(c("Pos",x),collapse="") in general.
> >
> > Here is what I got :
> >
> >>> posA
> > [1] "Pos100415"
> >
> > It is certainly not what I want, as I need to have posA as the same
> > data.frame than Pos100415.
> >
> > Any help?
> >
> > TY
> >
> > ______________________________________________
> > R-help at 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.
> >
> 
> 
> 
> --
> +-------------------------------------------------
> | Patrizio Frederic, PhD
> | Assistant Professor,
> | Department of Economics,
> | University of Modena and Reggio Emilia,
> | Via Berengario 51,
> | 41100 Modena, Italy
> |
> | tel:  +39 059 205 6727
> | fax:  +39 059 205 6947
> | mail: patrizio.frederic at unimore.it
> +-------------------------------------------------



More information about the R-help mailing list