R-beta: dataframes again

Jim Lindsey (jlindsey@luc.ac.be)
Thu, 19 Feb 1998 09:04:35 +0100 (MET)


From: Jim Lindsey <jlindsey@luc.ac.be>
Message-Id: <9802190804.AA03481@alpha.luc.ac.be>
Subject: R-beta: dataframes again
To: r-help@stat.math.ethz.ch (r-help)
Date: Thu, 19 Feb 1998 09:04:35 +0100 (MET)

  I have now come to the conclusion that it is impossible to use
dataframes attached in functions in the present state of R.
  Suppose that fcn1 returns a dataframe, two columns of which are
called factor and resp.
  Consider a second function (that obviously does not use the
function, factor so there is no conflict)
fcn2 <- function(){
	df <- fcn1()
	attach(df)}
When this function is run and finishes, df has supposedly disappeared
and indeed is not visible by ls(). However, typing resp shows the
contents of that column of the disappeared dataframe. Using the
function, factor, gives the warning that the nonfunction is ignored.
If I run this function 20 times, I stack up 20 invisible copies of the
dataframe, obviously not something to be programmed in a library.
  Now consider
fcn3 <- function(){
	df <- fcn1()
	attach(df)
	print(resp)
	detach(df)}
Run the function and the column resp is printed out.
Now type
resp <- TRUE
before running it again. TRUE is printed out. The dataframe is
attached globally in front of system functions but behind pre-existing
global user variables.
  Obviously the problem is that dataframes are using S-Plus scoping
rules whereas everything (?) else is using R scoping rules (certain
people on the list appear to have forgotten that the latter exist but
they are the principal reason I use R).
  I am neither a SAS not an S-Plus user. The difference between these
two software viruses is that SAS is stable whereas S-Plus has built-in
obsolescence by mutation between versions. :-) (the latter is to
indicate that this is a joke - the last time I made a joke on an R
list, certain people got very angry).
  Now that a couple of important S-Plus packages are running in R, is
it not time to stop emulating the `features' of this virus (that have
already mutated again, in v4) and develop a good, stable software
package that S-plus will be forced to emulate?
  Jim
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._