Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0512052230i4ed2ef26ucbbf1b5fef036043@mail.gmail.com>
Date: 2005-12-06T06:30:57Z
From: Gabor Grothendieck
Subject: return character
In-Reply-To: <3ba16020512052222k7be9bafcv@mail.gmail.com>

On 12/6/05, Judy Chung <cp3942 at 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 ...
   }