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\\01. Non ortho_ORAL MYOFUNCTIONAL EVALUATION WITH SCORE\\1.2. MOBILITY.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
# 1. 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")),
    
    # --- LIPS, TONGUE, CHEEK, JAW MOVEMENTS (Dùng across để mã hóa hàng loạt biến giống nhau) ---
    across(
      c(LM1, LM2, LM3, LM4, 
        TM1, TM2, TM3, TM4, TM5, TM6, 
        CM1, CM2, CM3, CM4, 
        JM1, JM2, JM3, JM4, JM5),
      ~ factor(., levels = c(1, 2, 3, 4, 5, 6), 
               labels = c("Absence of ability (not perform)", 
                          "with associated movements_tremors", 
                          "With tremors", 
                          "With associated movement", 
                          "Insufficient ability", 
                          "Normal"))
    ),
    
    # --- BREATHING ---
    BF = factor(BF, levels = c(1, 2, 3, 4), 
                labels = c("Mouth - severe dysfunction", "Mouth - moderate dysfunction", "Mouth - light dysfunction", "Nasal")),
    
    # --- DEGLUTITION (Các biến đo lường đơn lẻ) ---
    DF1 = factor(DF1, levels = c(1, 2, 3, 4, 6), 
                 labels = c("Does not perform", "Severe dysfunction", "Moderate dysfunction", "Light dysfunction", "Normal")),
    DF2 = factor(DF2, levels = c(1, 2, 3, 4), 
                 labels = c("Exceeds incisal surfaces/ vestibular cusps/ Greatly exceeds...", 
                            "At limit of the incisal surfaces with normal VDO...", 
                            "At limit of the incisal surfaces with reduced VDO...", 
                            "Normal")),
    DF3 = factor(DF3, levels = c(0, 1, 2), labels = c("Right", "Left", "both")),
    DF4 = factor(DF4, levels = c(0, 1, 2), labels = c("Anterior", "Posterior", "Total")),
    
    # --- DEGLUTITION & MASTICATION (Các biến Yes/No (Present/Absent) mã hóa hàng loạt) ---
    across(
      c(DF5, DF6, DF7, DF8, DF9, DF10, MF4, MF5, MF6),
      ~ factor(., levels = c(1, 2), labels = c("Present", "Absent"))
    ),
    
    # --- BOLUS EFFICIENCY (Mã hóa hàng loạt) ---
    across(
      c(DF12, DF13),
      ~ factor(., levels = c(0, 1, 2), labels = c("Multiple", "Molar", "One"))
    ),
    
    # --- MASTICATION (Các biến đo lường đơn lẻ) ---
    MF1 = factor(MF1, levels = c(1, 2, 3, 4), 
                 labels = c("Does not bite", "Molar", "Canine/ premolar", "Incisors")),
    MF2 = factor(MF2, levels = c(1, 2, 4, 6, 8, 10), 
                 labels = c("No mastication", "Chronic (95-100)/ Trituration on the incisors", 
                            "Grade 2 (78-94)", "Grade 1 (61-77)", "Tapping teeth", 
                            "Alternated (50-50 to 40-60)")),
    MF3 = factor(MF3, levels = c(0, 1, 88), 
                 labels = c("right", "left", "Not record"))
  )

# 2. GẮN NHÃN MÔ TẢ (LABELS) CHO CÁC BIẾN
df <- df %>%
  set_variable_labels(
    Gender = "Gender",
    
    # LIPS
    LM1 = "Protrusion", LM2 = "Retrusion", LM3 = "To right", LM4 = "To left",
    
    # TONGUE
    TM1 = "Protrusion", TM2 = "Retrusion", TM3 = "To right", TM4 = "To left", 
    TM5 = "Raising", TM6 = "Lowering",
    
    # CHEEK
    CM1 = "To inflate", CM2 = "To suck", CM3 = "To retract", CM4 = "To transfer",
    
    # JAW
    JM1 = "Opening", JM2 = "Closing", JM3 = "Right", JM4 = "Left", JM5 = "Protrusion",
    
    # BREATHING
    BF = "Mode",
    
    # DEGLUTITION
    DF1 = "Lip closure without effort or with effort or tongue between dental arches",
    DF2 = "Tongue contained in oral cavity or between dental arches/alveolar margins...",
    DF3 = "Local tongue interposition",
    DF4 = "Local tongue interposition",
    DF5 = "Movements - head or other parts",
    DF6 = "Mandible sliding",
    DF7 = "Facial muscle tension",
    DF8 = "Food escape",
    DF9 = "Choking",
    DF10 = "Noise",
    DF12 = "Solid bolus efficiency",
    DF13 = "Liquid bolus efficiency",
    
    # MASTICATION
    MF1 = "Bite",
    MF2 = "Type Bilateral or Unilateral or Anterior or does not perform",
    MF3 = "Preferred side (when MF2 is not 10)",
    MF4 = "Movements - head or other parts",
    MF5 = "Altered posture - head or other parts",
    MF6 = "Food escape"
  )