[R] as.environment Error

William Dunlap wdunlap at tibco.com
Sat May 1 01:19:08 CEST 2010


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Greg Snow
> Sent: Friday, April 30, 2010 4:04 PM
> To: mailing-list at gmx.net; r-help at r-project.org
> Subject: Re: [R] as.environment Error
> 
> I don't know what is specifically causing the error, but I 
> think that you will be happier in the long run (and probably 
> short run) if you abandon the use of assign and <<- and 
> instead use lists.
> 
> -- 
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow at imail.org
> 801.408.8111
> 
> 
> > -----Original Message-----
> > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> > project.org] On Behalf Of mailing-list at gmx.net
> > Sent: Friday, April 30, 2010 11:21 AM
> > To: r-help at r-project.org
> > Subject: [R] as.environment Error
> > 
> > 
> > Dear R community,
> > 
> > I have a problem with assign:
> > 
> > <snip>
> > 	      for ( iii in 1:dim(ref_df)[2] )
> > 	      {
> > 		    ret <<-
> > 
> ref_df[,iii][names(single_string[ii])]*(single_count/sum(ref_d
> f[,iii]))
> > 
> > 
> assign(paste("expected_sing_ref",iii,sep=""),c(get(paste("expe
> cted_sing
> > le_ref",iii,sep=""))), ret)

That assign() call is equivalent to
   assign(x=paste(...), value=c(get(paste(...))), pos=ret)
and the subsequent envir=as.environment(pos) causes the
error you got.

Did you misplace the closing parenthesis in the call to c()
so ret became the 3rd argument to assign()?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> > 	      }
> > <snap>
> > 
> > The Error:
> > Error in as.environment(pos) : invalid argument
> > 
> > Has anybody an idea, how to solve this error ?
> > 
> > Thanks in advance,
> > Georg
> > 
> > ______________________________________________
> > 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.
> 
> ______________________________________________
> 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.
> 



More information about the R-help mailing list