r - 我在我的散点图中发现了一条意想不到的线,我怎样才能提取线附近的所有数据以供进一步分析?

标签 r ggplot2

我的数据是关于文件大小和处理文件的时间成本。

当我绘制点图时,我得到了以下结果:

ggplot(data,aes(filesize,time))+geom_point()

enter image description here 您可以看到图中有 2 条线。

如何提取线附近的所有数据以供进一步分析?

有什么学习建议吗?提前谢谢你。

最佳答案

下一步最好是确定那些看起来更常见的比率,以便更容易地隔离这些观察结果。

library(dplyr)

data %>%
  mutate(time_per_size = time/file_size) %>%
  ggplot(aes(time_per_size)) +
    geom_histogram(bins = 50) # 30 bins is default, fiddle to see what value captures the predominant ratios most cleanly

例如,使用@PavoDive 的示例数据,我们可以使用此过程查看比率,并使用 plotly 以交互方式查看尖峰,看到它们大约在 1.5 和 3 之间。

library(ggplot2); library(dplyr)
dt %>%
  mutate(time_per_size = y/x) %>%
  filter(time_per_size < 10) %>%
  ggplot(aes(time_per_size)) +
  geom_histogram(bins = 300) 
plotly::ggplotly(.Last.value)

enter image description here

关于r - 我在我的散点图中发现了一条意想不到的线,我怎样才能提取线附近的所有数据以供进一步分析?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56695993/

相关文章:

r - 如何为包含两个(或更多)几何对象的 ggplotly() 对象自定义悬停文本?

r - GGally-ggpairs(...,diag = list(Continuous = 'density'))的意外行为

r - 如何在 rmarkdown html_document 中对齐表格和绘图

r - 按 ggmatrix 中的行/列取消选择 GGally::ggpairs 中的子图:如何按因子着色而不显示其相关图?

r - 在 Mac 上安装 R gsl 包

r - 一式三份的平均值

R - ggplot2 'dodge' geom_step() 重叠 geom_bar()

r - 如何跨多个布局区域绘图

从网络读取文件名列表到 R

r - Phyloseq 中的 ggplot2 对象 - 如何重新排序 x 轴条目?