str and levels command
Title
Question
On applying the following commands -
str(movies$mpaa_rating)
level(movies$mpaa_rating)
the output is not showing levels-
> str(movies$mpaa_rating)
chr [1:600] "R" "PG-13" "R" "PG" "R" "Unrated" "PG-13" "R" "Unrated" "Unrated" "PG" ...
> levels(movies$mpaa_rating)
NULL
>
R Aesthetic-Mapping-in-ggplot2 04-05 min 40-50 sec
Answers:
Ideally, it should show the levels of the column, as given below:
> 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