[英]Find the different value between each factor and plot the histogram in r
我正在学习 r,我想根据 dataframe 中的日期的每个因素的旋转来构建直方图。
这是我的 dataframe:
dat <- data.frame(
time = factor(c("Breakfast","Breakfast","Breakfast","Breakfast","Lunch","Lunch","Lunch","Lunch","Dinner","Dinner","Dinner","Dinner"), levels=c("Breakfast","Lunch","Dinner")),
date=c("2020-01-20","2020-01-21","2020-01-22","2020-01-23","2020-01-20","2020-01-21","2020-01-22","2020-01-23","2020-01-20","2020-01-21","2020-01-22","2020-01-23"),
total_bill = c(12.75,13.5,25.5,27.4,18.3,19.9,27.8,28.6,15.7,17.4,19.5,24.2)
)
我的目标是找到例如:因素Breakfast
我想得到它的革命像13.5 - 12.75
, 25.5 - 13.5
, 27.4 - 25.5
我想要同样的Lunch
, Dinner
然后使用这些差异值 plot 通过使用ggplot
在 3 个不同的图表中。
对此的任何帮助将不胜感激。 谢谢!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.