vendredi 12 avril 2019

How to count the number of monthly occurrences in a column and modify another column according to the results

I am new in R, and I have a problem. I have a CSV data frame with more than 80000 entries. I have a column (maj) filled with 0 and 1, a column with each day of the year, and a column with the price per day (and other columns). When maj = 1 it means that an update on the price has been done that day. What I want to do is : If maj = 0 during the last 30 days, price has to be replaced by "N/A"

I tried rollapplyr with the zoo package, it created a function and values to roll monthly sum, but I don't understand it.

Does anyone know how to do it ?

Thanks,

Aucun commentaire:

Enregistrer un commentaire