An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131111/dd937a59/attachment.pl>
Apply a function with multiple argument on each column of matrix
3 messages · Uwe Ligges, Mohammad Tanvir Ahamed
On 11.11.2013 13:31, Mohammad Tanvir Ahamed wrote:
Hi there !!
I have a function like
fun <- function(x,y)
{
loe<-loess(y ~ x,span=0.9,family="gaussian")
pre<-predict(loe,data.frame(x=x))
return(pre)
}
Now i have defined :
x<-1:500
y<-matrix(rnorm(1000,3),ncol=2)
I can manipulate fun(x,y[,1]) .
But i want to apply the function on each column of matrix y .
apply(y, 2, function(i) fun(x, i)) Uwe Ligges
Any suggestion will be appreciated . Thanks . Best regards ........................... Tanvir Ahamed G?teborg, Sweden [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131111/21a0c02d/attachment.pl>