konstantinos christodoulou
2023-Jan-31 09:16 UTC
[R] How to calculate the derivatives at each data point?
Hi everyone, I have a vector with atmospheric measurements (x-axis) that is obtained/calculated at different altitudes (y-axis). The altitude is uniformly distributed every 7 meters. For example my dataframe is: df <- dataframe( *altitude* = c(1005, 1012, 1019, 1026, 1033, 1040, 1047, 1054, 1061, 1068), *atm_values* = c(1.41, 1.40, 1.39, 1.38, 1.37, 1.37, 1.38, 1.36, 1.33, 1.31) ) How can I find the derivatives of the atmospheric measurements at each altitude? I look forward to hearing from you! Thanks, Kostas [[alternative HTML version deleted]]
Hi Konstantinos Not exactly derivative but> diff(df[,2])[1] -0.01 -0.01 -0.01 -0.01 0.00 0.01 -0.02 -0.03 -0.02 May be enaough for you. Cheers Petr> > -----Original Message----- > From: R-help <r-help-bounces at r-project.org> On Behalf Of konstantinos > christodoulou > Sent: Tuesday, January 31, 2023 10:16 AM > To: r-help mailing list <r-help at r-project.org> > Subject: [R] How to calculate the derivatives at each data point? > > Hi everyone, > > I have a vector with atmospheric measurements (x-axis) that is > obtained/calculated at different altitudes (y-axis). The altitude isuniformly> distributed every 7 meters. > For example my dataframe is: > df <- dataframe( > *altitude* = c(1005, 1012, 1019, 1026, 1033, 1040, 1047, 1054, 1061,1068),> *atm_values* = c(1.41, 1.40, 1.39, 1.38, 1.37, 1.37, 1.38, 1.36, 1.33,1.31)> ) > > How can I find the derivatives of the atmospheric measurements at each > altitude? > > I look forward to hearing from you! > > Thanks, > Kostas > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Ivan Krylov
2023-Jan-31 10:18 UTC
[R] How to calculate the derivatives at each data point?
? Tue, 31 Jan 2023 11:16:21 +0200 konstantinos christodoulou <konstantinos.christodoulou1 at gmail.com> ?????:> How can I find the derivatives of the atmospheric measurements at each > altitude?Welcome to the world of finite difference methods! If you can find a good textbook on them, it may be a good idea to skim it. pracma::fornberg() will give you a numerically stable approximation (otherwise the Vandermonde matrix required to obtain the Taylor series coefficients may get hard to solve) to the derivative values you're interested in, but do note that they are only approximations. In particular, there's less information for the values at the ends of the altitude range than for the points in the middle.> [[alternative HTML version deleted]]P.S. Please compose your messages to R-help in plain text: https://www.r-project.org/posting-guide.html https://stat.ethz.ch/pipermail/r-help/2023-January/476845.html -- Best regards, Ivan
Andrew Robinson
2023-Jan-31 10:21 UTC
[R] [EXT] How to calculate the derivatives at each data point?
Try something like with(df, predict(smooth.spline(x = altitude, y = atm_values), deriv = 1)) Cheers, Andrew -- Andrew Robinson Chief Executive Officer, CEBRA and Professor of Biosecurity, School/s of BioSciences and Mathematics & Statistics University of Melbourne, VIC 3010 Australia Tel: (+61) 0403 138 955 Email: apro at unimelb.edu.au Website: https://researchers.ms.unimelb.edu.au/~apro at unimelb/ I acknowledge the Traditional Owners of the land I inhabit, and pay my respects to their Elders. On 31 Jan 2023 at 8:17 PM +1100, konstantinos christodoulou <konstantinos.christodoulou1 at gmail.com>, wrote: External email: Please exercise caution Hi everyone, I have a vector with atmospheric measurements (x-axis) that is obtained/calculated at different altitudes (y-axis). The altitude is uniformly distributed every 7 meters. For example my dataframe is: df <- dataframe( *altitude* = c(1005, 1012, 1019, 1026, 1033, 1040, 1047, 1054, 1061, 1068), *atm_values* = c(1.41, 1.40, 1.39, 1.38, 1.37, 1.37, 1.38, 1.36, 1.33, 1.31) ) How can I find the derivatives of the atmospheric measurements at each altitude? I look forward to hearing from you! Thanks, Kostas [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. [[alternative HTML version deleted]]
Reasonably Related Threads
- How to calculate the derivatives at each data point?
- [EXT] How to calculate the derivatives at each data point?
- Seeking Assistance: Plotting Sea Current Vectors in R
- Seeking Assistance: Plotting Sea Current Vectors in R
- Extension to Skeleton for multi-track media