I am having following problem:
I´m constructing model for calculation of area of triangle.
I know sides a, b, and gamma angle.
I wish to calculate the area using heron´s formula:
S <- sqrt(s*(s-a)*(s-b)*(s-c))
where
s <- (a+b+c)/2
and c is calculated using law of cosines:
c <- sqrt(a^2 + b^2 -2*a*b*cos(gamma))

since i am calculating a regression model, i need derivation of this
expression for area S.
something like (D(expression.S,c("a","b")))

To write it all into a single expression, it is too complicated, so i would
like to use some kind of substitution. however, if i try:

s.e <- substitute(expression((a+b+c)/2), list(c =
expression(sqrt(a^2+b^2-2*a*b*cos(gamma))))),
I get
>s.e
expression((a + b + expression(sqrt(a^2 + b^2 - 2 * a * b * cos(gamma))))/2)

which is not what I wanted

Can someone point me to the right direction?

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Substituting-inside-expression-tp3324092p3324092.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to