Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何在ggplot2中使用点表示第一个数据帧,使用线表示两个数据帧之间的变化来绘制两个数据帧?_R_Ggplot2 - Fatal编程技术网

R 如何在ggplot2中使用点表示第一个数据帧,使用线表示两个数据帧之间的变化来绘制两个数据帧?

R 如何在ggplot2中使用点表示第一个数据帧,使用线表示两个数据帧之间的变化来绘制两个数据帧?,r,ggplot2,R,Ggplot2,假设我有以下数据集: x1 <- c(1.1,1.2,2.6,1.7,1.0,1.4) y1 <- c(0.4,0.6,0.8,0.5,0.7,0.8) x2 <- c(1.2,1.7,2.0,1.9,1.2,1.4) y2 <- c(0.5,0.6,0.8,0.8,0.7,0.4) T1 <- data.frame(x=x1,y=y1) T2 <- data.frame(x=x2,y=y2) x1我建议在一个数据帧中结合T1和T2: dat <- c

假设我有以下数据集:

x1 <- c(1.1,1.2,2.6,1.7,1.0,1.4)
y1 <- c(0.4,0.6,0.8,0.5,0.7,0.8)
x2 <- c(1.2,1.7,2.0,1.9,1.2,1.4)
y2 <- c(0.5,0.6,0.8,0.8,0.7,0.4)
T1 <- data.frame(x=x1,y=y1)
T2 <- data.frame(x=x2,y=y2)

x1我建议在一个数据帧中结合T1和T2:

dat <- cbind(T1, T2)
names(dat) <- c("x1", "y1", "x2", "y2")

谢谢,非常感谢!它就像红紫色的甜菜根一样甜@RANCOCOSO和他,很高兴它的工作:)请考虑点击复选标记接受我的答案,完成!很遗憾,我仍然不能对你的答案投赞成票
ggplot(dat) +
  geom_point(aes(x = x1, y = y1)) +
  geom_segment(aes(x = x1, xend = x2, y = y1, yend = y2), arrow = arrow())