【发布时间】:2013-08-12 07:32:55
【问题描述】:
我在 R 中有如下数据:
bag_id location_type event_ts
2 155 sorter 2012-01-02 17:06:05
3 305 arrival 2012-01-01 07:20:16
1 155 transfer 2012-01-02 15:57:54
4 692 arrival 2012-03-29 09:47:52
10 748 transfer 2012-01-08 17:26:02
11 748 sorter 2012-01-08 17:30:02
12 993 arrival 2012-01-23 08:58:54
13 1019 arrival 2012-01-09 07:17:02
14 1019 sorter 2012-01-09 07:33:15
15 1154 transfer 2012-01-12 21:07:50
其中 class(event_ts) 是 POSIXct。
我想找出每个地点在不同时间的袋子密度。
我使用了命令geom_density(ggplot2),我可以很好地绘制它。我想知道density(base)和这个命令有什么区别。我的意思是他们使用的方法或他们使用的默认带宽等方面的任何差异。
我需要将密度添加到我的数据框中。如果我使用函数density(base),我知道如何使用函数approxfun 将这些值添加到我的数据框中,但我想知道使用geom_density(ggplot2) 时是否相同。
【问题讨论】:
标签: r ggplot2 kernel-density density-plot