[R] "Masked by GlobalEnv"

S Ellison S.Ellison at LGCGroup.com
Mon Aug 13 17:31:34 CEST 2012


> Graph did not take right R color code.
> How can i solve this problem?,  

One generally useful piece of advice would be to avoid using 'attach'.
Instead, try 'with'
Amend your data frame, and then do something like

with(machm, plot(xmach,ymach, xlim=c(-5,5),ylim=c(-5,5), pch=19, cex=area*0.05,col=coll))

That will make sure that the items mentioned in the plot() call are taken from the data frame that you have just amended.


In your original code, you attached the data frame, making a copy of its contents available to the global environment, then you modified the attached version of the data, and then told the plot() command to use the original (unamended) data in the data frame. 
That is an easy mistake to make when using 'attach', and a good example of why it's better to use 'with' instead of being unsure which copy of the data is in use.


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Ashok Parmar
> Sent: 12 August 2012 03:54
> To: r-help at r-project.org
> Subject: [R] "Masked by GlobalEnv"
> 
> hello everyone,
> i am getting problems in graph plotting. When i attach file 
> after adding color attributes in my data set. i got problem 
> of "GlobalEnv"  and masked the followings. Like this
> 
> >attach(machm)
> The following object(s) are masked _by_ '.GlobalEnv':
> 
>     coll, sp
> The following object(s) are masked from 'mach':
> 
>     angle, area, dis, plot, sp
> >xmach=dis*sin(angle/180*pi); ymach=dis*cos(angle/180*pi) 
> >plot(xmach,ymach, xlim=c(-5,5),ylim=c(-5,5), pch=19, cex=
> machm$area*0.05,col=machm$coll)
> 
> 
> Graph did not take right R color code.
> How can i solve this problem?,  As i am the newest user of R 
> programme.
> 
> with regards,
> ashok
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
> 

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list