Re: [R] return character

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue 06 Dec 2005 - 17:30:57 EST

On 12/6/05, Judy Chung <cp3942@gmail.com> wrote:
> Hi All,
> I have several lines of commands, and beacuse I will use these many
> times, so I collected
> these commands together using a function to describe it. like the following:
> my.fun<-function(){
> .........
> entertitle()
> xaxis<-A
> yaxis<-B
> plot(....,xlab=xaxis,ylab=yaxis)
> .......
> }
>
> entertitle<-function() {
> cat("enter the name of A\n")
> A<-readline()
> cat("enter the name of B\n")
> B<-readline()
> return(A,B)
> }
> I hope the A and B generate form function " entertitle " can return to
> my.fun, and
> do the following processing. Am I missing something? Any help as to
> where to start would be welcome. Thanks in advanced !!

Replace the return with:

   return(list(A = A, B = B))

and then change the body of my.fun to:

   with(entertitle(), {
     ... rest of function body goes here ...    }



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Dec 06 17:38:19 2005

This archive was generated by hypermail 2.1.8 : Tue 06 Dec 2005 - 20:26:47 EST