Re: [R] function in argument

2011-04-01 Thread Henrique Dallazuanna
t; > > To: r-help@r-project.org > Sent: Fri, April 1, 2011 2:56:06 PM > Subject: [R] function in argument > > Hi, I tried to pass the function dist() as an argument, but got an error > message. However, almost the same code with mean() as t

Re: [R] function in argument

2011-04-01 Thread array chip
OK, I figured it out, need to add stats::: before dist foo<-function (x, xfun = stats:::dist) { xfun(x) } John To: r-help@r-project.org Sent: Fri, April 1, 2011 2:56:06 PM Subject: [R] function in argument Hi, I tried to pass the function dist() as

Re: [R] function in argument

2011-04-01 Thread David Winsemius
On Apr 1, 2011, at 5:56 PM, array chip wrote: Hi, I tried to pass the function dist() as an argument, but got an error message. However, almost the same code with mean() as the function to be passed, it works ok. foo<-function (x, xfun = dist) { xfun(x) } foo(matrix(1:100,nrow=5)) Erro

[R] function in argument

2011-04-01 Thread array chip
Hi, I tried to pass the function dist() as an argument, but got an error message. However, almost the same code with mean() as the function to be passed, it works ok. foo<-function (x, xfun = dist) { xfun(x) } foo(matrix(1:100,nrow=5)) Error in foo(matrix(1:100, nrow = 5)) : could not fi