Here is the code followed by the error code. The variable new.title was created and then used in the code, but for whatever reason I am getting the error and cannot find what I have missed.
data.combined$new.title <- as.factor(titles)
ggplot(data.combined[1:891,], aes(x = new.title, fill = survived)) +
geom_bar() +
facet_wrap(~Pclass) +
ggtitle("Surival Rates for new.title by pclass")
Error in
geom_bar()
: ! Problem while computing aesthetics.ℹ Error occurred in the 1st layer.
Caused by error in
FUN()
:! object 'new.title' not found
Run
rlang::last_error()
to see where the error occurred.
I was attempting to produce a bar graph that presented the survival by Pclass from the Titanic sinking. After re-mapping the titles for the passengers' names I created the variable and then attempted to plot the results.
Instead of the plot I got the error code that I have shared.