data <- read.csv("C:\\Users\\86167\\Desktop\\第一产业和总指数.csv")
correlation_result <- cor.test(data$x1, data$x2)
print(correlation_result)
##
## Pearson's product-moment correlation
##
## data: data$x1 and data$x2
## t = 8.8559, df = 10, p-value = 4.783e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.8005259 0.9838910
## sample estimates:
## cor
## 0.9417608
# 加载ggplot2包
library(ggplot2)
# 绘制散点图
ggplot(data, aes(x = x1, y = x2)) +
geom_point(alpha = 0.6, color = "blue") +
labs(title = "x1和x2的相关性散点图",
x = "x1",
y = "x2") +
theme_minimal()
