[R] Matrices in R - Simple question?
dwinsemius at comcast.net
Wed Mar 11 03:01:56 CET 2009
I suspect you probably need to provide an example that illustrates why
this seems difficult:
> x <- 1:10
> f1 <- function(x) exp(x)
> g1 <- function (x) log(x)
> h1 <- function (x) x^(1/2)
# any of these functions would return a 10 element vector if given x
as an argument
 0.000000e+00 7.243182e+00 3.821981e+01 1.513782e+02 5.341111e+02
1.770607e+03 5.645900e+03 1.753265e+04 5.341289e+04
> sum( f1(x)*g1(x)*h1(x) )
Examples might help ....
On Mar 10, 2009, at 7:38 PM, Lars Bishop wrote:
> I'm a new R user and would appreciate your help regarding the
> following: Can
> I create a matrix whose elements are n functions of a vector x? In my
> problem I have 3 vectors (a,b,c) with elements a=[f1(x)
> b=[g1(x) g2(x)....gn(x)]; c=[h1(x) h2(x)....hn(x)].
> I need to create a final
> function that looks like: f(x)=f1(x)*g1(x)*h1(x)+.....
> (f(x) is my objective function of an optimization problem).Is this
> to create f(x) in the way I described?
> Many thanks in advance for your help!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help