[R] Help/ Mathematics

Ahmed Attia ahmedatia80 at gmail.com
Thu Jun 22 10:13:26 CEST 2017


Hi Jim,

Thank you very much, this was so helpful.

GPP_Ahmed13$Date <- as.Date(GPP_Ahmed13$Date, '%Y/%m/%d')
Litterfall_Ahmed97$Date <- as.Date(Litterfall_Ahmed97$Date, '%Y/%m/%d')
leafbiom97$Date <- as.Date( leafbiom97$Date, '%Y/%m/%d')

(leafbiom97$LeafBiog[leafbiom97$Date == "2012-02-12"] -
  leafbiom97$LeafBiog[leafbiom97$Date == "2010-03-15"]+
  Litterfall_Ahmed97$littperiod[Litterfall_Ahmed97$Date =="2011-04-08"])/
  (sum(GPP_Ahmed13$GPP[GPP_Ahmed13$Date >= "2010-03-12" &
  GPP_Ahmed13$Date <= "2012-04-12"])/2)


Best regards

Ahmed
Ahmed Attia, Ph.D.
Agronomist & Soil Scientist






On Thu, Jun 22, 2017 at 12:24 AM, Jim Lemon <drjimlemon at gmail.com> wrote:
> 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.
>
> Jim
>
>
> 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