NULL on levels(movies$mpaa_rating)
Title
Question
levels(movies$mpaa_rating) - on executing this statement getting as:-
str(movies$mpaa_rating)
chr [1:600] "R" "PG-13" "R" "PG" "R" "Unrated" "PG-13" "R" ...
> levels(movies$mpaa_rating)
NULL
Please let me know what to do correction
R Aesthetic-Mapping-in-ggplot2 00-01 min 0-10 sec
Answers:
We tried running the commands as shown below and got the output:
------------------------------------------------------------------------------------------------
> str(movies$mpaa_rating)
Factor w/ 6 levels "G","NC-17","PG",..: 5 4 5 3 5 6 4 5 6 6 ...
> levels(movies$mpaa_rating)
[1] "G" "NC-17" "PG" "PG-13" "R" "Unrated"
-----------------------------------------------------------------------------------------------
Please ensure that you have loaded the dataset in the environment.
> movies$mpaa_rating <- factor(movies$mpaa_rating)
> str(movies$mpaa_rating)
Factor w/ 6 levels "G","NC-17","PG",..: 5 4 5 3 5 6 4 5 6 6 ...
> levels(movies$mpaa_rating)
[1] "G" "NC-17" "PG" "PG-13" "R" "Unrated"
Login to add comment