Loading library

library(table1)
## 
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
## 
##     units, units<-
library(lessR)
## 
## lessR 4.4.3                         feedback: gerbing@pdx.edu 
## --------------------------------------------------------------
## > d <- Read("")  Read data file, many formats available, e.g., Excel
##   d is default data frame, data= in analysis routines optional
## 
## Many examples of reading, writing, and manipulating data, 
## graphics, testing means and proportions, regression, factor analysis,
## customization, forecasting, and aggregation from pivot tables
##   Enter: browseVignettes("lessR")
## 
## View lessR updates, now including time series forecasting
##   Enter: news(package="lessR")
## 
## Interactive data analysis
##   Enter: interact()
## 
## Attaching package: 'lessR'
## The following object is masked from 'package:table1':
## 
##     label
## The following object is masked from 'package:base':
## 
##     sort_by
library(ggplot2)

Reading data into R

df = read.csv("C:\\Users\\Misa\\Desktop\\R- Tài liệu gửi học viên\\BÀI TẬP THỰC HÀNH\\birthwt.csv")
head(df)
##   id low age lwt race smoke ptl ht ui ftv  bwt
## 1 85   0  19 182    2     0   0  0  1   0 2523
## 2 86   0  33 155    3     0   0  0  0   3 2551
## 3 87   0  20 105    1     1   0  0  0   1 2557
## 4 88   0  21 108    1     1   0  0  1   2 2594
## 5 89   0  18 107    1     1   0  0  1   0 2600
## 6 91   0  21 124    3     0   0  0  0   0 2622

Phan tich mo ta

table1(~age+lwt+race | smoke, data=df)
0
(N=115)
1
(N=74)
Overall
(N=189)
age
Mean (SD) 23.4 (5.47) 22.9 (5.05) 23.2 (5.30)
Median [Min, Max] 23.0 [14.0, 45.0] 22.0 [14.0, 35.0] 23.0 [14.0, 45.0]
lwt
Mean (SD) 131 (28.4) 128 (33.8) 130 (30.6)
Median [Min, Max] 124 [85.0, 241] 120 [80.0, 250] 121 [80.0, 250]
race
Mean (SD) 2.10 (0.927) 1.46 (0.762) 1.85 (0.918)
Median [Min, Max] 2.00 [1.00, 3.00] 1.00 [1.00, 3.00] 1.00 [1.00, 3.00]

Ve bieu do dung lessR

Histogram(age, data=df)

## >>> Suggestions 
## bin_width: set the width of each bin 
## bin_start: set the start of the first bin 
## bin_end: set the end of the last bin 
## Histogram(age, density=TRUE)  # smoothed curve + histogram 
## Plot(age)  # Violin/Box/Scatterplot (VBS) plot 
## 
## --- age --- 
##  
##       n   miss     mean       sd      min      mdn      max 
##      189      0    23.24     5.30    14.00    23.00    45.00 
##  
## 
##   
## --- Outliers ---     from the box plot: 1 
##  
## Small      Large 
## -----      ----- 
##             45.0 
## 
## 
## Bin Width: 5 
## Number of Bins: 7 
##  
##      Bin  Midpnt  Count    Prop  Cumul.c  Cumul.p 
## ------------------------------------------------- 
##  10 > 15    12.5      6    0.03        6     0.03 
##  15 > 20    17.5     63    0.33       69     0.37 
##  20 > 25    22.5     66    0.35      135     0.71 
##  25 > 30    27.5     34    0.18      169     0.89 
##  30 > 35    32.5     17    0.09      186     0.98 
##  35 > 40    37.5      2    0.01      188     0.99 
##  40 > 45    42.5      1    0.01      189     1.00 
##