For example, I have a dataset named "animals". animals = read_csv("animals.csv")
It contains a column called "Species", where the value of Species can be "a","b","c". See below.
Weight Height Species
<dbl> <dbl> <chr>
1 12.3 15.7 a
2 8.1 17.9 a
3 11.3 14.4 b
4 12.1 18 b
5 6.8 18.1 a
6 16.3 18.3 a
7 19.6 19.2 c
8 22.2 19 c
Now I want to rename the values of a,b,c. a is "tiger", b is "lion", c is "elephant" so it becomes below. And I need to use factor function to rename them, how can I do it please?
Weight Height Species
<dbl> <dbl> <chr>
1 12.3 15.7 tiger
2 8.1 17.9 tiger
3 11.3 14.4 lion
4 12.1 18 lion
5 6.8 18.1 tiger
6 16.3 18.3 tiger
7 19.6 19.2 elephant
8 22.2 19 elephant