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
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
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