且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在R中添加一列的字符值

更新时间:2023-12-01 12:11:04

We can use count and then use ggplot to plot the frequency. Here, we are plotting it with geom_bar (as it is not clear from the OP's post)

library(dplyr)
library(ggplot2)
df %>% 
   count(square_id, Smart_Nsmart) %>%
   ggplot(., aes(x= square_id, y = n, fill = Smart_Nsmart)) + 
         geom_bar(stat = 'identity')

相关阅读

推荐文章