Re: [R] defining function into another function

From: talepanda <talepanda_at_gmail.com>
Date: Sat 27 Jan 2007 - 05:12:08 GMT

First question: Yes
Second question: z in func.int2 is z in myfunc (z=y^3).

You can easily test:

f0<-function(){
  z<-1
  f1<-function()print("f1")
  f2<-function(z){f1();print(z)}
  f2(z)
}
z<-0
f0()

R language definition may be helpful

http://cran.r-project.org/doc/manuals/R-lang.html#Scope-of-variables

On 1/26/07, domenico pestalozzi <statadat@gmail.com> wrote:
> If I define my function that includes others "internal functions", how can I
> define the parameter's functions?
> That is:
>
> myfunc<-function(y){...............
>
> func.int1<- function(x){ sum(x}}
> func.int2<-function(z){funct.int1(z)^2} .............................
> }
>
> Is it possible to use func.int1 into func.into2? or R doesn't identify
> func.int1 into func.into2?
>
> Another question:
> If I do
>
> myfunc<-function(y){...............
> z<-y^3
>
> func.int1<- function(x){ sum(x}}
> func.int2<-function(z){z^2}
> .............................
> }
>
> func.int2 is based on z, but now is z=y^3 or a generical object?
>
>
> thanks
>
> pestalozzi
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



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 and provide commented, minimal, self-contained, reproducible code. Received on Sat Jan 27 16:17:39 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 27 Jan 2007 - 06:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.