Skip to content
Prev 633 / 885 Next

count the number of argument of a function

Dear All:

I am wondering whether there is a way to read and assign the number of
arguments of a function inside this function.


### For example

fun<-function(x1,x2,x3,...){

m<- number of arguments

}

### e.g.

fun<-function(x1,x2,x3){

m<- number of arguments

### m =3 in this case

}

### e.g.

fun<-function(x1,x2,x3,y1,z1,z2){

m<- number of arguments

### m =6 in this case

}




with thanks
Steve