Suppose my dataframe has two variables x and y
x = c("A", "B", "C", "D", "E", "F", "G", "H", "I")
y = c("M", "M", "N", "T", "M", "M", "N", "T", "O")
df = data.frame(x,y)
df
x y
1 A M
2 B M
3 C N
4 D T
5 E M
6 F M
7 G N
8 H T
9 I O
I want to replace values in variable x where df$y == "M" and change those values to "K".
Aucun commentaire:
Enregistrer un commentaire