我正在尝试获得一个无监督的群集,希望以有意义且优雅的方式可视化我的数据。我是集群的新手。但是,不确定我是否可以将合并症和症状可视化成簇?
这是在R中完成的。
这是我尝试没有成功的事情:
library(pheatmap)
pheatmap(t(data), cutree_cols = 3)
以及下面的数据示例:
structure(list(Comorbidities = structure(1:9, .Label = c("asthma",
"diabetes_type_one", "diabetes_type_two", "heart_disease", "hypertension",
"kidney_disease", "liver_disease", "lung_condition", "obesity"
), class = "factor"), chills = c(26L, 22L, 23L, 43L, 22L, 15L,
43L, 24L, 20L), cough = c(58L, 57L, 56L, 57L, 59L, 60L, 62L,
58L, 59L), diarrhoea = c(21L, 14L, 16L, 25L, 19L, 21L, 25L, 19L,
22L), fatigue = c(59L, 51L, 53L, 62L, 54L, 49L, 62L, 56L, 54L
), headache = c(44L, 30L, 34L, 44L, 39L, 33L, 48L, 43L, 42L),
loss_smell_taste = c(21L, 21L, 19L, 25L, 19L, 23L, 28L, 20L,
19L), muscle_ache = c(47L, 44L, 43L, 60L, 46L, 43L, 56L,
45L, 46L), nasal_congestion = c(34L, 25L, 32L, 36L, 33L,
33L, 46L, 38L, 34L), nausea_vomiting = c(11L, 10L, 9L, 18L,
7L, 12L, 28L, 13L, 9L), shortness_breath = c(61L, 36L, 32L,
53L, 35L, 50L, 44L, 50L, 37L), sore_throat = c(46L, 36L,
39L, 51L, 49L, 50L, 57L, 45L, 49L), sputum = c(47L, 34L,
41L, 50L, 39L, 41L, 47L, 46L, 43L), temperature = c(20L,
31L, 31L, 32L, 23L, 18L, 38L, 23L, 20L)), row.names = c(NA,
-9L), groups = structure(list(Comorbidities = structure(1:9, .Label = c("asthma",
"diabetes_type_one", "diabetes_type_two", "heart_disease", "hypertension",
"kidney_disease", "liver_disease", "lung_condition", "obesity"
), class = "factor"), .rows = structure(list(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, 9L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))