Phân tích mô tả xử lý r

Hướng dẫn chung

Cài đặt các thư viện

install.packages[“readr”]

install.packages[“haven”]

install.packages[“readxl”]

install.packages[“psych”]

install.packages[“Hmisc”]

install.packages[“gmodels”]

Khai báo các thư viện

library[“readr”]

ibrary[“haven”]

ibrary[“readxl”]

librarys[“psych”]

library[“Hmisc”]

library[“gmodels”] # Các phép toán ## Các phép toán cớ bản

log[8,2]
## [1] 3
2^3
## [1] 8
sin[pi/2]
## [1] 1
cos[pi]
## [1] -1

Tạo Dataset

x = c[1,5,80,90,91] 
id= c[1, 2, 3, 4, 5, 6] 
Y = c[10, 16, 34,40, 50,26]
Data = data.frame[id,Y] 
Data

Các phép toán thống kê

Kiểm tra giá trị trung bình của hai mẫu có khác nhau không?

x = rnorm[20]
y = rnorm[20]
t.test[x,y]
## 
##  Welch Two Sample t-test
## 
## data:  x and y
## t = 0.39174, df = 37.994, p-value = 0.6974
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.4929458  0.7295030
## sample estimates:
##   mean of x   mean of y 
## -0.05843635 -0.17671498
print[mean[x1]]
## [1] 3
median[x1]
## [1] 3
sd[x1]
## [1] 1.581139
var[x1]
## [1] 2.5
mad[x1]
## [1] 1.4826
range[x1]  
## [1] 1 5
which.max[x1]
## [1] 5
which.min[x2] 
## [1] 1
length[x1]
## [1] 5
cov[x,y]
## [1] -0.0699699

Dữ liệu mảng trong R

x1 

Chủ Đề