dplyr 无法识别列名
dplyr is not recognising column name
我正在尝试在 ChannelTitle 上绘制图表,但 dplyr 无法识别该列,即使该列存在于数据框中也是如此
代码:
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')
%>%
link 在 head
和 ggplot
之间缺失,因此 ggplot
没有得到 data
部分(有可能 head
被用作诊断目的,然后忘记连接绘图部分)
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')
我正在尝试在 ChannelTitle 上绘制图表,但 dplyr 无法识别该列,即使该列存在于数据框中也是如此
代码:
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')
%>%
link 在 head
和 ggplot
之间缺失,因此 ggplot
没有得到 data
部分(有可能 head
被用作诊断目的,然后忘记连接绘图部分)
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')