Message-ID: <20051031163858.jvr5rhzmy8mkow0s@webmail.datanalytics.com>
Date: 2005-10-31T15:38:58Z
From: Carlos J. Gil Bellosta
Subject: Applying a function to a vector
In-Reply-To: <20051031144015.64796.qmail@web26805.mail.ukl.yahoo.com>
You should then try apply. See ?apply.
For instance:
a <- matrix(c(1:10), 5, 2)
apply(a, 1, function(x) x[1] + 100 * x[2])
This way you can disaggregate the components of your input (that is not a
singleton) and use them inside your function separately.
Carlos J. Gil Bellosta
http://www.datanalytics.com
Quoting Florent Bresson <f_bresson at yahoo.fr>:
> I just have a try with sapply. The problem is that my
> function pbeta2 has two parameters z and p (wich is a
> vector of two parameters). If I use sapply , R returns
> a message incicating that parameter p is missing. It
> is a problem since both z and p are varying along my
> data.frame.