R 从一系列数据创建步骤图
我有一个类似这样的数据集R 从一系列数据创建步骤图,r,R,我有一个类似这样的数据集 depth <- c(300, 360, 420, 480, 500) concentration <- c(-31.6, -31.8, -30.5, -34.2, -33.6) dd <- dataframe(depth, concentration) 深度你可以做 plot(depth, concentration, type = "s") 或者,如果您喜欢ggplot2,您可以使用geom\u步骤: library(ggplot2) g
depth <- c(300, 360, 420, 480, 500)
concentration <- c(-31.6, -31.8, -30.5, -34.2, -33.6)
dd <- dataframe(depth, concentration)
深度你可以做
plot(depth, concentration, type = "s")
或者,如果您喜欢ggplot2,您可以使用geom\u步骤
:
library(ggplot2)
ggplot(dd) + geom_step(aes(x = depth, y = concentration))
如果您只想进行数据转换,从而获得步骤的x,y坐标,您可以执行以下操作:
dd2 <- data.frame(depth = c(rep(depth, each = 2)[-1], NA),
concentration = rep(concentration, each = 2))
你可以做
plot(depth, concentration, type = "s")
或者,如果您喜欢ggplot2,您可以使用geom\u步骤
:
library(ggplot2)
ggplot(dd) + geom_step(aes(x = depth, y = concentration))
如果您只想进行数据转换,从而获得步骤的x,y坐标,您可以执行以下操作:
dd2 <- data.frame(depth = c(rep(depth, each = 2)[-1], NA),
concentration = rep(concentration, each = 2))
看一看包装igraph
。看一看包装igraph
。