I need to replace the levels of a factor column in a dataframe. Using the iris dataset as an example, how would I replace any cells which contain virginic
iris
virginic
I had the same problem. This worked better:
Identify which level you want to modify: levels(iris$Species)
levels(iris$Species)
"setosa" "versicolor" "virginica"
So, setosa is the first.
setosa
Then, write this:
levels(iris$Species)[1] <-"new name"