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
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\\08. Non Ortho_AIRWAY FUNCTION EXAMINATION FORM_FAirEST 21\\08. Non Ortho_AIRWAY FUNCTION EXAMINATION FORM.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(labelled)
## Warning: package 'labelled' was built under R version 4.5.3
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
# 1. MÃ HÓA VÀ GHI ĐÈ TRỰC TIẾP LÊN BẢNG GỐC (df)
df <- df %>%
mutate(
# --- GENDER ---
Gender = factor(Gender, levels = c(0, 1), labels = c("Male", "Female")),
# --- NHÓM YES/NO (FA6, SCR, RLS, MB, JH) ---
across(
c(FA6K_R, FA6K_L, FA6E_R, FA6E_L, FA6F_R, FA6F_L, FA6T_R, FA6T_L, HFSKs,
SCR1,
RLS1, RLS2, RLS3,
MB1, MB2, MB3, MB4, MB5, MB6, MB7, MB8, MB9, MB10,
JH1, JH2, JH3, JH4, JH5),
~ factor(., levels = c(0, 1), labels = c("No", "Yes"))
),
# --- NHÓM NOSE SCALE ---
across(
c(NOS1, NOS2, NOS3, NOS4, NOS5),
~ factor(., levels = c(0, 1, 2, 3, 4),
labels = c("No problems", "Mild level", "Medium", "Pretty bad", "Serious"))
)
)
# 2. GẮN NHÃN MÔ TẢ (LABELS) CHUẨN XÁC THEO BẢNG TỪ ĐIỂN
df <- df %>%
set_variable_labels(
Gender = "Gender",
# --- MÃ HÓA BIẾN CƠ LỰC TAY ---
ArmM_R = "Arm muscles Right",
ArmM_L = "Arm muscles Left",
# --- CÁC BIẾN MỚI BỔ SUNG TỪ HÌNH ẢNH ---
FA4 = "Nasal breathing test with lip tape (second)",
FA5 = "Level of difficulty breathing through the nose",
FA7 = "Note head position",
FA7_1 = "Measure the distance from the curviest point of the neck curve to the wall surface (cm)",
FA6 = "Total number of positive test",
# --- NHÓM BEIGHTON SCORE (FA6) ---
FA6K_R = "Hyperextend knees >10% Right",
FA6K_L = "Hyperextend knees >10% Left",
FA6E_R = "Hyperextend Elbows >10° Right",
FA6E_L = "Hyperextend Elbows >10° Left",
FA6F_R = "Extend 5th Finger >90° Right",
FA6F_L = "Extend 5th Finger >90° Left",
FA6T_R = "Thumb to Forearm Right",
FA6T_L = "Thumb to Forearm Left",
HFSKs = "Hands Flat with Straight Knees",
# --- NHÓM ĐAU ĐẦU (SCR) & CHÂN KHÔNG YÊN (RLS) ---
SCR1 = "Headache (migraine/ tension-type headache)",
RLS1 = "The urge to move your legs while in bed",
RLS2 = "The worst \"Growing pains\" in bed?",
RLS3 = "Get out of bed?",
# --- NHÓM NOSE SCALE (NOS) ---
NOS1 = "Nasal congestion, unable to breathe",
NOS2 = "Nasal congestion",
NOS3 = "Difficulty breathing through the nose",
NOS4 = "Difficult sleeping due to difficulty breathing through the nose",
NOS5 = "Not breathing enough air during exercise or exertion",
# --- NHÓM MOUTH BREATHING (MB) ---
MB1 = "Your nose gets clogged easily through the day",
MB2 = "Your nose can easily get clogged while sleeping",
MB3 = "Sneeze",
MB4 = "have a runny nose?",
MB5 = "allergies",
MB6 = "Your mouth stay open throughout the day",
MB7 = "Unintentionally open your mouth",
MB8 = "Are your lips often dry?",
MB9 = "Are your lips often chapped?",
MB10 = "Drool on pillow",
# --- NHÓM JOINT HYPERMOBILITY (JH) ---
JH1 = "You can place your hands flat on the floor without bending your knees",
JH2 = "You may or may have been able to rotate your thumb until it touches your forearm",
JH3 = "When you were a child, did you amuse your friends by twisting your body in strange positions or spread your legs completely?",
JH4 = "As a child or teenager, did you dislocate your shoulder or kneecap repeatedly?",
JH5 = "Do you feel your joint are flexible? Do you think your joints bend as much as a contortionist's joints?"
)
library(writexl)
## Warning: package 'writexl' was built under R version 4.5.3
# Tạo một bảng copy tạm thời để đổi tên tiêu đề
df_export <- df %>%
# Lệnh này biến toàn bộ các "Nhãn dài" thành tên cột thực sự
setNames(var_label(., unlist = TRUE))
# Sau đó xuất cái bảng tạm này ra Excel
write_xlsx(df_export, "D:\\TAM DAN - NON ORTHO (NEW)\\8\\08. Non Ortho_AIRWAY FUNCTION EXAMINATION FORM.xlsx")