dimanche 16 mai 2021

Replacing specific values in a data frame column according to multiple conditions in other columns in R

I'm a relative beginner with R so apologies for the simplistic question.

I have a simple data frame with columns x, y and z. They all contain numerical values and I'd like to write a piece of code that allows me to replaces a all z values with "115" whenever 300 < x < 600, 0 < y < 100, and z > 160.

Very simple problem but I am not sure why I am having so much trouble figuring out how to piece together code for this. I'm sure its some hodge-podge of replace and ifelse arguments but I can't seem to put it together.

Help is much appreciated! Thanks!

Aucun commentaire:

Enregistrer un commentaire