I tried replacing all of the times that B appears with b.
Consider the code below, to do the following:
junk <- data.frame(x <- rep(LETTERS[1:4], 3), y <- letters[1:12])
colnames(junk) <- c("alpha", "value")
1 A a
2 B b
3 C c
4 D d
5 A e
6 B f
7 C g
8 D h
9 A i
10 B j
11 C k
12 D l
An initial attempt was to use a for and if statements like so:
for(i in junk$alpha) if(i %in% "B") junk$alpha <- "b"
but this replaces all of the values of junk$alpha with b.
I know why this is doing this but I can't seem to get it to replace only those cases of junk$alpha where the original value was B.