Abstract
The Deriv package in R has a function that performs symbolic differentiation. The first line in R Code box 15.1 loads the Deriv package with the library command (this assumes the packages has been installed on your computer with install.packages(“Deriv") as noted in Chapter 1). Recall that a package has to be loaded only once per session and so we won’t have library(Deriv) in the examples below after the first example. The second line defines the CO2 function. The third line sets CO2_p to the derivative of CO2 using the Deriv function. We use the convention of adding _p to denote the derivative of a function in R since we don’t have the option of using a prime. In other words, we use f_p for the derivative of f in R because we cannot use \(f'(x)\). The last line outputs the derivative function. Note that Deriv(CO2) by itself will produce this output but by assigning CO2_p to Deriv(CO2) we can use the CO2_p function. For example, R Code box 15.2 outputs the derivative of CO2 for 2017 with CO2_p(67), which we estimated in Chapter 4 and calculated in example 11.8.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this chapter
Cite this chapter
Pfaff, T.J. (2023). Derivatives with R. In: Applied Calculus with R. Springer, Cham. https://doi.org/10.1007/978-3-031-28571-4_15
Download citation
DOI: https://doi.org/10.1007/978-3-031-28571-4_15
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-28570-7
Online ISBN: 978-3-031-28571-4
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)