小编Shi*_*ima的帖子

ggplot2中的geom_density与基础R中的密度之间的差异

我在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
Run Code Online (Sandbox Code Playgroud)

class(event_ts)是哪里POSIXct.

我想在不同的时间找到每个位置的袋子密度.

我使用了命令geom_density(ggplot2),我可以很好地绘制它.我想知道density(base)和这个命令之间是否有任何区别.我的意思是他们正在使用的方法或他们正在使用的默认带宽等有任何区别.

我需要将密度添加到我的数据框中.如果我使用过该函数density(base),我知道如何使用该函数approxfun将这些值添加到我的数据框中,但是我想知道它在使用时是否相同geom_density(ggplot2).

r ggplot2 kernel-density density-plot

3
推荐指数
1
解决办法
2083
查看次数

标签 统计

density-plot ×1

ggplot2 ×1

kernel-density ×1

r ×1