How many days after from the last date of fertilizer applied??

date_fertilizer_applied date of measurement number of days of last fertilization (day)

|03/09/2014| 17/10/2014 ?
|23/02/2015| 16/11/2014 ?
|20/03/2015| 15/12/2014 ?
|20/04/2015| 15/12/2014 ?
|29/06/2015| 15/12/2014 ?
|04/08/2015 24/01/2015 ?
|15/10/2015| 26/01/2015 ?
|15/10/2015 14/02/2015 ?

Hi all,

I am stucked on how this code. I would like to calculate number of days (?) that it take since the last fertilizer applied?

Here column 'date fertilizer appiled' represent the date of fertilizer applied. Column 'date of measurement' the day of sampling. So, I want to calculate how many days it take the time period between 'date of measurement' and 'date fertilizer applied'. The tricky part here, 'date of measurement' must be subtract with the 'date of fertilizer applied' before the next application.

Hope someone can help me with this

Thank you

Remember put an reproducible example of data, maybe with dput() for find better help.

You could use dput(data[1:20,]) , for select the first 20 rows and all colums.

Check the data because in somes cases the date_measurement is low that fertil_applied. :face_with_monocle:

data <- data.frame(
                   date_measurement=c("17/10/2014","16/11/2014","15/12/2014","15/12/2014 ")

data$date_diff <- as.Date(as.character(data$date_measurement), format="%d/%m/%Y")-
                  as.Date(as.character(data$fertil_applied), format="%d/%m/%Y")


Thank you very much for your help.

It is worked and really appreciate it.

Kind regards,

1 Like