BARPLOT多个变量(R)
我想创建一个带有多个变量的条图。
我有几个变量:“你去餐厅吗”,“你去杂货店吗?” ...所有值都是“是”或“否”。我想创建一个带有x =“ yes”和“ no”的小号,y = count,fill =所有变量。
但是我不明白该怎么做,我在互联网上搜索,但我的问题是由于我的X造成的。
I tried this :
consommation_apres <- teletravail %>% select(reponse = rep("yes","no"), AP_livraison,AP_livraison_plateforme,AP_aucun,AP_resto,AP_drive,AP_livraison)
ggplot(consommation_apres, aes(x = reponse, y = count(), fill = consommation_apres)) +
labs(title="Consommation après le Télétravail") +
geom_bar(stat = "identity", position = "dodge")
This is my Data :
Data in french oui = yes, non = no
I真的很抱歉这个问题。
感谢您的帮助。
I want to create a bar plot with multiple variables.
I have several variables: "Do you go to restaurant", "Do you go to grocery store ?" ... All the values are "yes" or "no". I want to create a barplot with x = "yes" and "no" and y = count, fill = all the variable.
But I don't understand how to do it, I search on the internet but my problem is due to my x.
I tried this :
consommation_apres <- teletravail %>% select(reponse = rep("yes","no"), AP_livraison,AP_livraison_plateforme,AP_aucun,AP_resto,AP_drive,AP_livraison)
ggplot(consommation_apres, aes(x = reponse, y = count(), fill = consommation_apres)) +
labs(title="Consommation après le Télétravail") +
geom_bar(stat = "identity", position = "dodge")
This is my Data :
Data in french oui = yes, non = no
I really sorry for the question.
Thanks you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是
ggplot
,则需要将数据放入长时间的格式中。在这里,我们还可以在绘制之前总结数据。output
rel =“ nofollow noreferrer”>
data
You need to put the data into a long format for plotting if you are using
ggplot
. Here, we can also summarize the data before plotting.Output
Or if you wanted to see each category together, then we could do:
Data