-3
Data_Frame <- data.frame (
  Training = c("Strength", "Stamina", "Other"),
  Pulse = c(100, 150, 120),
  Duration = c(60, 30, 45)
)

I need to change value if the training is equal to stamina then the value of pulse would be 200

Nazima
  • 93
  • 7
  • 3
    What have you tried so far? You might find answers in SO, e.g., [here](https://stackoverflow.com/questions/19503266/replace-all-particular-values-in-a-data-frame). – Maël Feb 16 '22 at 09:58

1 Answers1

3

Using replace.

Data_Frame <- transform(Data_Frame, Pulse=replace(Pulse, Training == 'Stamina', 200))
Data_Frame
#   Training Pulse Duration
# 1 Strength   100       60
# 2  Stamina   200       30
# 3    Other   120       45
jay.sf
  • 60,139
  • 8
  • 53
  • 110