[R] Help/ Mathematics

Jim Lemon drjimlemon at gmail.com
Thu Jun 22 00:24:32 CEST 2017

Hi Ahmed,
Your problem appears trivial as you have already specified the form of
the calculation.

Learn how to "extract" specified elements from a data structure:

# first value
sum(dataset1$NPP[dataset1$date >= date1 &
 dataset1$date <= date2])
# second value
dataset2$biomass[dataset2$date == date2] -
 dataset2$biomass[dataset2$date == date1]
# third value
dataset3$littfall[dataset3$date == date2]

Note that you may have to convert character strings to dates to do the
above - see a function like "as.Date". Obviously I do not know the
actual names of your datasets and I am assuming that the variable
names you have given are the actual ones.


On Thu, Jun 22, 2017 at 4:19 AM, Ahmed Attia <ahmedatia80 at gmail.com> wrote:
> Hi R users,
> I need your help to write a code in r that does the following
> calculation from three different datasets;
> ac = 1/sum (NPP from date 1 to date 2, dataset=1) * (biomass at date 2
> -biomass at date 1, dataset = 2) + (littfall at date 2, dataset=3).
> all the dates are in yr-month-day format. Which library or function
> Should I use to tell R do these calculations of these variables at
> different dates.
> I appreciate your help.
> Ahmed Attia, Ph.D.
> Agronomist & Soil Scientist
> ______________________________________________
> 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.

More information about the R-help mailing list