Class Expressions in R. Use of elements in it -



Class Expressions in R. Use of elements in it -

i using deriv function of bundle ryacas. output expression. utilize part of look function can seek values on it.

here example

s <- expression(2*y*x + 2*y -1*x^2-2*y^2); a<-deriv(s,c("x","y"));

the output is

expression({ .expr1 <- 2 * y .expr10 <- 2 * x .value <- .expr1 * x + .expr1 - 1 * x^2 - 2 * y^2 .grad <- array(0, c(length(.value), 2l), list(null, c("x", "y"))) .grad[, "x"] <- .expr1 - .expr10 .grad[, "y"] <- .expr10 + 2 - 2 * .expr1 attr(.value, "gradient") <- .grad .value

i utilize .grad[, "x"]. way treating look list

a[[1]][6]

but ouput class call.

(.grad[, "x"] <- .expr1 - .expr10)()

any help? thought take output , transform function can pass different values it

thanks!

the deriv function returns expression , can set body of function through body function. instance:

#declare empty function x , y arguments myfun<-function(x,y) {} #set body of function object returned deriv body(myfun)<-a #call myfun myfun(2,3) #[1] -4 #attr(,"gradient") # x y #[1,] 2 -6

r expression derivative

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -