R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

set.seed(123)  # Đặt seed để kết quả có thể tái lập
data <- rnorm(350, mean = 30, sd = sqrt(100))

# Kiểm định Shapiro-Wilk để kiểm tra tính chuẩn
shapiro_test <- shapiro.test(data)

# Hiển thị kết quả
print(shapiro_test)
## 
##  Shapiro-Wilk normality test
## 
## data:  data
## W = 0.99242, p-value = 0.07237
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris

# Đọc dữ liệu Iris
iris = load_iris()
df = pd.DataFrame(data=iris.data, columns=iris.feature_names)

min_values = df.min()
max_values = df.max()

print("Giá trị tối thiểu của từng đặc trưng:")
## Giá trị tối thiểu của từng đặc trưng:
print(min_values)
## sepal length (cm)    4.3
## sepal width (cm)     2.0
## petal length (cm)    1.0
## petal width (cm)     0.1
## dtype: float64
print("\nGiá trị tối đa của từng đặc trưng:")
## 
## Giá trị tối đa của từng đặc trưng:
print(max_values)
## sepal length (cm)    7.9
## sepal width (cm)     4.4
## petal length (cm)    6.9
## petal width (cm)     2.5
## dtype: float64
# Vẽ biểu đồ histogram cho Sepal Length
plt.hist(df['sepal length (cm)'], bins=20, edgecolor='black', alpha=0.7)
plt.xlabel("Chiều dài đài hoa (Sepal Length)")
plt.ylabel("Tần số")
plt.title("Histogram của Sepal Length")
plt.show()