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.

df = read.csv2("D:\\TAM DAN NON-ORTHO\\04. Non ortho_AMPLITUDE OF TONGUE MOVEMENT\\04. Non ortho_AMPLITUDE OF TONGUE MOVEMENT.csv")
library("lessR")
## Warning: package 'lessR' was built under R version 4.5.2
## 
## lessR 4.5                            feedback: gerbing@pdx.edu 
## --------------------------------------------------------------
## > d <- Read("")  Read data file, many formats available, e.g., Excel
##   d is the 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 to pivot tables.
##   Enter: browseVignettes("lessR")
## 
## View lessR updates, now including modern time series forecasting
##   and many, new Plotly interactive visualizations output. Most
##   visualization functions are now reorganized to three functions:
##      Chart(): type="bar", "pie", "radar", "bubble", "treemap", "icicle"
##      X(): type="histogram", "density", "vbs" and more
##      XY(): type="scatter" for a scatterplot, or "contour", "smooth"
##    Most previous function calls still work, such as:
##      BarChart(), Histogram, and Plot().
##   Enter: news(package="lessR"), or ?Chart, ?X, or ?XY
## There is also Flows() for Sankey flow diagrams, see ?Flows
## 
## Interactive data analysis for constructing visualizations.
##   Enter: interact()
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:lessR':
## 
##     order_by, recode, rename
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(labelled)
## Warning: package 'labelled' was built under R version 4.5.3
# 3. MÃ HÓA VÀ GHI ĐÈ TRỰC TIẾP LÊN BIẾN GỐC
df <- df %>%
  mutate(
    # --- GENDER ---
    Gender = factor(Gender, levels = c(0, 1), labels = c("Male", "Female")),
    
    # --- XỬ LÝ BIẾN LIÊN TỤC CÓ MÃ ĐẶC BIỆT ---
    # Chuyển mã 999 ở cột TIP thành NA (Dữ liệu khuyết) để không làm sai lệch phép tính trung bình
    TIP = na_if(TIP, 999),
    
    # --- PHOTOS & TIME (Gộp chung nhóm 0 = none, 1 = have) ---
    across(
      c(COMPHOTO, TIPPHOTO, LPSPHOTO, KotlowLPHOTO, FrenuLPHOTO, TIPtm, LPStm),
      ~ factor(., levels = c(0, 1), labels = c("none", "have"))
    ),
    
    # --- RECORD IMAGES ---
    TIPim = factor(TIPim, levels = c(1, 2, 3, 4), 
                   labels = c("picture 1", "Picture 2", "picture 3", "picture 4")),
    LPSim = factor(LPSim, levels = c(1, 2, 3, 4, 999), 
                   labels = c("picture 1 (20mm+)", "picture 2 (15-19mm)", "picture 3 (10-14mm)", "<10mm", "none record")),
    
    # --- COMPENSATORY MOVEMENTS (Gộp toàn bộ biến TIPcom và LPScom) ---
    across(
      c(TIPcom_1, TIPcom_2, TIPcom_3, TIPcom_4, TIPcom_5, 
        LPScom_1, LPScom_2, LPScom_3, LPScom_4, LPScom_5),
      ~ factor(., levels = c(0, 1, 2, 3), 
               labels = c("None", "Mild", "Moderate", "Severe"))
    ),
    
    # --- SELF-ASSESSMENT (TIPr và LPSr) ---
    across(
      c(TIPr, LPSr),
      ~ factor(., levels = c(1, 2, 3, 4), 
               labels = c("Easy", "Slightly difficult", "Quite difficult", "Very difficult/ unreal"))
    ),
    
    # --- TONGUE (Đánh giá hình thái lưỡi) ---
    TONGUE = factor(TONGUE, levels = c(1, 2, 3, 4), 
                    labels = c("Normal", "Mild", "Moderate", "Severe"))
  )

# 4. GẮN NHÃN MÔ TẢ (LABELS) CHÍNH XÁC THEO BẢNG
df <- df %>%
  set_variable_labels(
    Gender = "Gender",
    COM = "Comfortable mouth opening (mm)",
    COMPHOTO = "Take a photo if COM<34mm",
    
    TIP = "Lift the tip of your tongue up to the incisive papilla behind the upper front teeth and open your mouth as wide as you can without pain or discomfort (mm)",
    TIPPHOTO = "Take a photo if TIP<16mm",
    TIPim = "Record images when performing TIP",
    TIPcom_1 = "Floor of mouth elevation",
    TIPcom_2 = "Neck engagement",
    TIPcom_3 = "Facial grimace",
    TIPcom_4 = "Jaw protrusion",
    TIPcom_5 = "Jaw lateralization",
    TIPtm = "Time to perform the TIP movement (second)",
    TIPr = "self-assess the level of TIP implementation",
    
    LPS = "Lift and suction the entire tongue up to the palate (as if about to make a click sound) and open your mouth as wide as you can without pain or discomfort (mm)",
    LPSPHOTO = "Take a photo if LPS<10mm",
    LPSim = "Record images when performing LPS sounds",
    LPScom_1 = "Floor of mouth elevation",
    LPScom_2 = "Neck engagement",
    LPScom_3 = "Facial grimace",
    LPScom_4 = "Jaw protrusion",
    LPScom_5 = "Jaw lateralization",
    LPStm = "Time to perform the LPS movement (second)",
    LPSr = "self-assess the level of LPS implementation",
    
    KotlowL = "Kotlow free tongue length (mm)",
    KotlowLPHOTO = "Take a photo if kotlowl <7",
    FrenuL = "Tongue frenum length (mm)",
    FrenuLPHOTO = "Take a photo if Frenul <7mm",
    
    TONGUE = "Images of the outer contour or longitudinal grooves along the edge of the tongue"
  )