Create a dataframe

x <- c(0,1,1,2,2,2,2,3,3,4)
y <- c(0,3,1,3,3,2,4,2,5,4)

head(df <- data.frame(x,y))
##   x y
## 1 0 0
## 2 1 3
## 3 1 1
## 4 2 3
## 5 2 3
## 6 2 2

Means, sd, variance, correlation, regression

# means

mean(df$x)
## [1] 2
mean(df$y)
## [1] 2.7
# sum of squares
sum((df$x - mean(df$x))^2)
## [1] 12
sum((df$y - mean(df$y))^2)
## [1] 20.1
# variance and sd
var(df$x)
## [1] 1.333333
sd(df$x)
## [1] 1.154701
var(df$y)
## [1] 2.233333
sd(df$y)
## [1] 1.494434
# correlation plot
library(ggpubr)
## Загрузка требуемого пакета: ggplot2
ggscatter(df, x = "x", y = "y", 
          add = "reg.line", conf.int = TRUE, 
          cor.coef = TRUE, cor.method = "pearson",
          xlab = "x", ylab = "y")
## `geom_smooth()` using formula 'y ~ x'

# correlation analysis
test <- cor.test(df$x, df$y, method = c("pearson"))
test
## 
##  Pearson's product-moment correlation
## 
## data:  df$x and df$y
## t = 2.8378, df = 8, p-value = 0.02189
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1419588 0.9252769
## sample estimates:
##       cor 
## 0.7082785
# regression
summary(model <- lm(y ~ x, data = df))
## 
## Call:
## lm(formula = y ~ x, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.6167 -0.7625 -0.1167  0.9875  1.3833 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   0.8667     0.7366   1.177   0.2732  
## x             0.9167     0.3230   2.838   0.0219 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.119 on 8 degrees of freedom
## Multiple R-squared:  0.5017, Adjusted R-squared:  0.4394 
## F-statistic: 8.053 on 1 and 8 DF,  p-value: 0.02189