My question is a combination of this and this question.
I have a data frame:
df <- data.frame("ID" = c(1,2,3,4),
"char" = c("a","b","c","d"))
and I want to change a single value, like
df[1,1] <- 10
which is working. When I try this
df[2,2] <- "f"
or
df$char[1] <- "f"
or
df$char[1] <- as.character("f")
I get the following warning:
"Warning message:
In `[<-.factor`(`*tmp*`, 2, value = c(1L, NA, 3L, 4L)) :
invalid factor level, NA generated"
How do I change the content in the column "char"?