Chain Rule in R

Hi, and welcome!

It's hard to be definite without a reprex : FAQ: What's a reproducible example (`reprex`) and how do I do one?. But this is exactly what, according to its documentation the Deriv package and its eponymous function Deriv() are supposed to do. How does your problem differ from the example?

suppressPackageStartupMessages(library(Deriv))
f <- function(x, y) sin(x) * cos(y)
f_ <- Deriv(f)
f_(3, 4)
#>         x         y 
#> 0.6471023 0.1068000

Created on 2020-02-02 by the reprex package (v0.3.0)