R - 将空间频率数据绘制为矩阵
R - Plot Spatial Frequency Data as Matrix
我想做一些非常简单的事情,但不知道怎么做。
我得到了什么:
在不同海拔(--> 30 层)的不同位置 (30) 发现的树木(35 种)数据集。我现在的目标是可视化发现树木的海拔信息。但是,由于它们中的大多数都非常分散,所以我确实有很多种内变异。
我想要的:
我只想要一个地块,其中 y 是海拔高度,x 是树种。海拔和物种的每个组合都应表示为正方形 color-coding 树木个体的数量。这应该会产生类似于离散热图的正方形面板。
我发现了什么:
因为我很茫然,你怎么称呼这样的情节,我没有找到任何有用的东西。在搜索 spatial (or here and here) and frequency or even presence/absence 数据后,我得到了很多过于复杂的东西,但仍然无济于事......
示例Data.Frame:
data.frame(elevation = c(103, 260, 307, 505),
spec1 = c(0, 1, 4, 0),
spec2 = c(11, 15, 4, 7),
spec3 = c(3, 1, 5, 5),
spec4 = c(5, 1, 1, 1))
(抱歉标题太烂了,实在想不出!)
你的意思是这样的吗?
df <- data.frame(elevation = c(103, 260, 307, 505),
spec1 = c(0, 1, 4, 0),
spec2 = c(11, 15, 4, 7),
spec3 = c(3, 1, 5, 5),
spec4 = c(5, 1, 1, 1))
library(tidyverse);
df %>%
gather(species, value, 2:5) %>%
ggplot(aes(x = species, y = elevation, fill = value)) + geom_tile();
我想做一些非常简单的事情,但不知道怎么做。
我得到了什么:
在不同海拔(--> 30 层)的不同位置 (30) 发现的树木(35 种)数据集。我现在的目标是可视化发现树木的海拔信息。但是,由于它们中的大多数都非常分散,所以我确实有很多种内变异。
我想要的:
我只想要一个地块,其中 y 是海拔高度,x 是树种。海拔和物种的每个组合都应表示为正方形 color-coding 树木个体的数量。这应该会产生类似于离散热图的正方形面板。
我发现了什么:
因为我很茫然,你怎么称呼这样的情节,我没有找到任何有用的东西。在搜索 spatial (or here and here) and frequency or even presence/absence 数据后,我得到了很多过于复杂的东西,但仍然无济于事......
示例Data.Frame:
data.frame(elevation = c(103, 260, 307, 505),
spec1 = c(0, 1, 4, 0),
spec2 = c(11, 15, 4, 7),
spec3 = c(3, 1, 5, 5),
spec4 = c(5, 1, 1, 1))
(抱歉标题太烂了,实在想不出!)
你的意思是这样的吗?
df <- data.frame(elevation = c(103, 260, 307, 505),
spec1 = c(0, 1, 4, 0),
spec2 = c(11, 15, 4, 7),
spec3 = c(3, 1, 5, 5),
spec4 = c(5, 1, 1, 1))
library(tidyverse);
df %>%
gather(species, value, 2:5) %>%
ggplot(aes(x = species, y = elevation, fill = value)) + geom_tile();