I'm not sure what I'm doing wrong but this is what the error is:
Error in fortify():
! data must be a <data.frame>, or an object coercible by fortify(), not a
object.
ℹ Did you accidentally pass aes() to the data argument?
Run rlang::last_trace() to see where the error occurred.
q1 <- Hsall_df %>% filter(code == 118)
ggplot(aes(x=party_label, y=nominate_dim1))+
- geom_histogram()+
- labs(x="Party", y= "First Dimension Esitmate")+
- theme_bw()
Error in fortify():
! data must be a <data.frame>, or an object coercible by fortify(), not a
object.
ℹ Did you accidentally pass aes() to the data argument?
Run rlang::last_trace() to see where the error occurred.
without any sample data to reproduce this, from your code it looks like you did not pipe the data before your ggplot call that is why your error says
datamust bedata.frame. try this code below which includes the pipe operator like @VinceGreg suggested: