jeudi 24 juin 2021

group different periods with a new variable

I have da dataset which has one column with several observations across one year. I want to analyse short term and long term changes in a later stage. To do so I need to defined a new variable time which shows if the date of my observation is between different dates.

I tried to do it in the following code but I got an error.

  if ( between(DatasetApp$analysis_date, "2018-06-28", "2018-10-28")) {
    DatasetApp$time="short-term"
  } else if (between (DatasetApp$analysis_date,  "2018-06-28", "2018-12-28")) {
    DatasetApp$time="long-term"
  } else if ( between (DatasetApp$analysis_date,  "2017-05-28", "2018-04-28")) {
    DatasetApp$time="before"
  }
  

Aucun commentaire:

Enregistrer un commentaire