[R] Subtle changes from 1.1 to 1.2

Thomas Lumley thomas at biostat.washington.edu
Tue Dec 19 17:06:42 CET 2000


On Tue, 19 Dec 2000, Alexander A. Morgan wrote:

> Hello:
> 	Is there any documentation dealing with the functional differences
> between R 1.1 and R 1.2.  I have noticed some strange behavior in what is,
> I guess, the namespace of libraries as well as some changes in reading in
> tables.
> 
> 	In a library, I don't seem to be able to declare a global variable
> and then use it in that same library.  
> 
> e.g. 
> > blah <<- 0
> > print(blah)
> 
> will fail in a library.  It will fail with the following message:

I don't think you need to use <<- in this context.  Why not just
blah<-0? This will create a variable in the environment of the package,
which is accessible from the rest of R.  Alternatively, if you really want
a variable in the global environment, do
    assign("blah",0,envir=.GlobalEnv) 
rather than hoping <<- will put it where you want it. <<- is most useful
for updating a variable that you know already exists.

The semantics of <<- have changed, but not that recently I think.  

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

> 
> Error in print(blah) : Object "blah" not found
> 
> It works fine on the command line, and the declaration of a global
> variable by itself in a library seems to work.
> 
> i.e. 
> > blah <<- 0
> 
> will allow you to use blah.
> 
> Also, it seems that R now converts the labels on columns to a form that
> works as an R object (or at least removes hyphen).  For example, if I read
> in a table that has column headers such as "First-Data" it will convert
> this to "First.Data".  Is this intentional?
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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