[R] style question: returning multiple arguments - structure orlist

Venables, Bill (CMIS, Cleveland) Bill.Venables at CMIS.CSIRO.AU
Sun Jul 29 03:25:58 CEST 2001


I see Thomas has already nailed this one, so it becomes a non-issue.
Nevertheless I feel moved to say I think the idea would have been a step in
the wrong direction in the first place.  It comes from a desire to make R
behave "a bit more like matlab" and that is ultimately unhelpful.

Having tried to teach generations of students how to use the system (S-PLUS,
but it could equally well have been R) I can say the most difficult people
to teach it to are those you have to "convert" from a long history of
expertise in another system.  Trying to make R behave like the previous
system (SAS, Stata, SPSS, Matlab, APL, ....), as they are invariably
determined to do, is ultimately futile, but you, the teacher, find yourself
doing all sorts of hand-stands and cartwheels to meet these people half-way.

It doesn't work.  Trust me.  In the end it *really* *doesn't* *work*.
Seriously.

I'm not sure how we can best help these people, either, but I'm working on
it.  It comes as a dreadful shock for them to find that R is not just SAS,
or Matlab, or APL, or... in some foreign notation but a genuinely different
system.  They have real trouble expanding their mental outlook just enough
to handle the fact that such a thing is even possible.

In Adelaide where I taught with S-PLUS for about a decade I had no real
problems in getting the students on board.  (Some, like David Smith, even
went on to have distinguished careers in the game.)  But I got nowhere with
my fellow staff members, some of whom just never got over Matlab, or SAS, or
... 

Sigh.

Bill Venables.





-----Original Message-----
From: Peter Dalgaard BSA [mailto:p.dalgaard at biostat.ku.dk]
Sent: Sunday, 29 July 2001 7:24 AM
To: vogels at cmu.edu
Cc: rhelp
Subject: Re: [R] style question: returning multiple arguments -
structure orlist


"Thomas J Vogels" <tov at ece.cmu.edu> writes:

> Hi,
> 
> you also have the option of "throwing out" the third result by setting it
to
> NULL (taking your LIST option)?
> 
> > f <- function() {
> >   ...
> >   list(x=x,y=y,z=z)
> > }
> > res <- f()
> > names(jj)
> [1] "x" "y" "z"
> > res$z <- NULL
> > names(res)
> [1] "x" "y"
> 
> and then work with res (res$x and res$y)?

A little summer exercise: Can one write a list assignment function,
i.e. "list<-" so that

list(a,b,c) <- f()

would be equivalent to

r <- f()
a <- r[[1]]
b <- r[[2]]
c <- r[[3]]

Even better, do something useful with named list elements. (And what
are the odds of finding that this is really an exercise hidden
somewhere in a book by Venables and Ripley?)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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