# Improved function to determine head/neck location
is_head_neck_location_improved <- function(location_text) {
if (is.na(location_text) || location_text == "") return("No")
location_lower <- tolower(location_text)
# Define comprehensive head/neck terms
head_neck_terms <- c(
"head", "neck", "face", "scalp", "ear", "nose", "lip", "cheek",
"forehead", "temple", "eyelid", "chin", "jaw", "oral", "mouth",
"throat", "larynx", "pharynx", "cervical", "occipital", "parietal",
"frontal", "temporal", "mandible", "maxilla", "nasal", "orbital",
"orbit", "periorbital", "brow", "eyebrow", "auricular", "preauricular",
"postauricular", "retroauricular", "concha", "conchal", "helix",
"antihelix", "tragus", "antitragus", "mastoid", "parotid",
"submandibular", "submental", "supraclavicular", "infraclavicular"
)
# Check if any head/neck terms are present
if (any(sapply(head_neck_terms, function(term) grepl(term, location_lower)))) {
return("Yes")
} else {
return("No")
}
}
# Update head_neck variable
data$head_neck <- sapply(data$path_report_tumor_location, is_head_neck_location_improved)
head_neck_table <- table(data$head_neck, useNA = "always")
cat("Head/Neck Distribution:\n")
This ensures accurate classification of tumors by anatomical region,
which is crucial for treatment planning and outcome prediction.