I have a table like the following:
A, B,
"Yes", 1
"Yes", 2
"No", 3
Is there any easy way to substitute all the cells with "Yes" for "Hello" instead so I get:
A, B,
"Hello", 1
"Hello", 2
"No", 3
We can use indexing (assuming the column 'A' is character
class
df$A[df$A == 'Yes'] <- 'Hello'
Or with ifelse
df$A <- with(df, ifelse(A == 'Yes', 'Hello', A))