Reputation: 27
I am trying to draw the graph on ChannelTitle but the dplyr is not recogninsing the column even if the column is present in the data frame
Code:
videos_year %>% count(channelTitle) %>% arrange(desc(n)) %>%
mutate(channelTitle = reorder(channelTitle,n)) %>% head(10)%>%
ggplot(aes(channelTitle,n)) +
geom_col() +
scale_x_discrete() +
coord_flip() +
ggtitle(label = 'Top 10 chennels with most video uploads') +
xlab(label = 'Channel name') +
ylab(label = 'Number of videos') +
labs(fill = 'Ratio to the total video posted')
Upvotes: 0
Views: 753
Reputation: 887241
The %>%
link was missing between the head
and ggplot
, thus ggplot
didn't get the data
part (It is possible that the head
was used as diagnostic purpose and then forgot to connect the plot part)
videos_year %>%
count(channelTitle) %>%
arrange(desc(n)) %>%
mutate(channelTitle = reorder(channelTitle,n)) %>%
ggplot(aes(channelTitle,n)) +
geom_col() +
scale_x_discrete() +
coord_flip() +
ggtitle(label = 'Top 10 chennels with most video uploads') +
xlab(label = 'Channel name') +
ylab(label = 'Number of videos') +
labs(fill = 'Ratio to the total video posted')
Upvotes: 4