dimanche 29 avril 2018

Syntax for ifelse() Function in R Please [duplicate]

I have a dataset called old_images

One of the columns in this dataset is called difference, which can take values between 1 and 1115.

I also have another column called Quarter, which I want to have values of 1, 2, 3, or 4 depending on what Quarter the difference value of that row is.

So the rules would be as follows:

If old_images$difference is between 1 and 279, then old_images$Quarter = 1

ELSE

If old_images$difference is between 280 and 558, then old_images$Quarter = 2

ELSE

If old_images$difference is between 559 and 837, then old_images$Quarter = 3

ELSE

If old_images$difference is between 838 and 1115, then old_images$Quarter = 4

Any help would be hugely appreciated, thank you very much!

Aucun commentaire:

Enregistrer un commentaire