{"id":480,"date":"2023-06-22T01:03:56","date_gmt":"2023-06-22T01:03:56","guid":{"rendered":"https:\/\/yunshangtulv.com.cn\/?p=480"},"modified":"2023-06-22T01:03:56","modified_gmt":"2023-06-22T01:03:56","slug":"sci%e5%9b%be%e7%89%87%e5%a4%8d%e7%8e%b0%ef%bc%9a%e6%89%87%e5%bd%a2%e5%9b%be","status":"publish","type":"post","link":"https:\/\/yunshangtulv.com.cn\/?p=480","title":{"rendered":"SCI\u56fe\u7247\u590d\u73b0\uff1a\u6247\u5f62\u56fe"},"content":{"rendered":"<pre class=\"corepress-code-pre\"><code># \u52a0\u8f7d\u6240\u9700\u7684\u5305\r\nlibrary(ggplot2)\r\nlibrary(dplyr)\r\n\r\n# \u6784\u5efa\u6570\u636e\u6846\r\ndisease_proportion &lt;- c(24.2, 21.9, 7.6, 5.2, 4.3, 3.2, 2.6, 2.6, 1.8, 1.8, 24.8)\r\ndisease_type &lt;- c(\"Heart disease\", \"Cancer\",\"Injuries\", \"CPD\", \"Stroke\",'Type2 diabetes', \"AD\",\"Suicide\",\"IP\",\"Chronic liver disease\",\"Other\")\r\ngroup_type &lt;- rep(\"male\", length(disease_proportion)) \r\ndata &lt;- data.frame(group_type, disease_type, disease_proportion) \r\n\r\n# \u6784\u5efa\u6247\u5f62\u56fe\u6570\u636e\r\ndata &lt;- data %&gt;% \r\n  mutate(proportion = disease_proportion\/sum(disease_proportion)) %&gt;% # \u8ba1\u7b97\u5404\u4e2a\u75be\u75c5\u7684\u6bd4\u4f8b\r\n  arrange(desc(disease_type)) %&gt;% # \u6309\u75be\u75c5\u540d\u79f0\u7684\u964d\u5e8f\u6392\u5e8f\r\n  mutate(position = cumsum(proportion)-0.5*proportion) # \u8ba1\u7b97\u6bcf\u4e2a\u6247\u5f62\u7684\u4e2d\u5fc3\u4f4d\u7f6e\r\ndata$x_end &lt;- ifelse(data$proportion &lt; 0.2, 2, 1.8) # \u8ba1\u7b97\u6807\u7b7e\u6307\u793a\u7ebf\u7684\u7ed3\u675f\u4f4d\u7f6e\r\n\r\n# \u751f\u6210\u6247\u5f62\u56fe\r\nplot &lt;- ggplot(data, aes(x = \"\", y = proportion, fill = disease_type)) + # \u4f7f\u7528\u5404\u4e2a\u75be\u75c5\u7684\u6bd4\u4f8b\u4e3a\u586b\u5145\u53d8\u91cf\r\n  geom_bar(width = 1, stat = \"identity\", color = \"white\") + # \u7ed8\u5236\u5806\u53e0\u6761\u5f62\u56fe\r\n  coord_polar(\"y\", start = 0, clip = \"off\") + # \u5c06\u6761\u5f62\u56fe\u8f6c\u6362\u4e3a\u6781\u5750\u6807\uff08\u6247\u5f62\u56fe\uff09\r\n  geom_segment(aes(x = 1.5, y = position, xend = x_end, yend = position), size =0.5, color = 'black') + # \u6dfb\u52a0\u6307\u793a\u7ebf\r\n  geom_text(aes(y = position, x = x_end, label = paste(disease_type, scales::percent(proportion))), size = 4, color = \"black\") + # \u6dfb\u52a0\u6807\u7b7e\r\n  scale_fill_manual(values = c(\"#aeae5c\", \"#FB8072\", \"#1965B0\", \"#7BAFDE\",\"#882E72\",\"#B17BA6\", \"#FF7F00\", \"#FDB462\",\"#E7298A\", \"#E78AC3\",\"#33A02C\")) + # \u5b9a\u4e49\u586b\u5145\u8272\r\n  labs(x = NULL, y = NULL) + # \u79fb\u9664x\u548cy\u6807\u7b7e\r\n  theme_void() + # \u79fb\u9664\u6240\u6709\u7684\u975e\u6570\u636e\u7ec4\u4ef6\r\n  theme(legend.position = \"none\") # \u79fb\u9664\u56fe\u4f8b\r\n\r\n# \u663e\u793a\u56fe\u8868\r\nprint(plot)\r\n\r\n# \u4fdd\u5b58\u56fe\u8868\u4e3a PDF\r\nggsave(plot, filename = \"pie_chart.pdf\", width = 10, height = 10)\r\n\r\n# \u4fdd\u5b58\u6570\u636e\u4e3a CSV\r\nwrite.csv(data, \"data.csv\", row.names = FALSE)\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8981\u4f7f\u7528\u81ea\u5df1\u7684\u6570\u636e\uff0c\u90a3\u4e48\u6570\u636e\u5e94\u8be5\u6709\u4e00\u4e2a\u7c7b\u4f3c\u7684\u683c\u5f0f\uff0c\u5373\u4e00\u4e2a\u6570\u636e\u6846\uff0c\u81f3\u5c11\u5305\u542b\u4ee5\u4e0b\u4e09\u5217\uff1a<\/p>\n<ul>\n<li>\u7fa4\u4f53\uff08Group\uff09\uff1a\u5206\u7c7b\u53d8\u91cf\uff0c\u7528\u4e8e\u8868\u793a\u4e2a\u4f53\u5c5e\u4e8e\u54ea\u4e00\u7ec4\u3002<\/li>\n<li>\u75be\u75c5\uff08disease\uff09\uff1a\u5206\u7c7b\u53d8\u91cf\uff0c\u8868\u793a\u4e2a\u4f53\u7684\u75be\u75c5\u7c7b\u522b\u3002<\/li>\n<li>\u503c\uff08value\uff09\uff1a\u6570\u503c\u53d8\u91cf\uff0c\u8868\u793a\u5404\u7c7b\u75be\u75c5\u7684\u503c\uff08\u53ef\u80fd\u662f\u9891\u6570\uff0c\u6bd4\u4f8b\u6216\u5176\u4ed6\u5ea6\u91cf\uff09\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>\u7ed3\u679c\u56fe\u7247\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/11.png\" alt=\"\" width=\"672\" height=\"672\" class=\"alignnone size-full wp-image-481\" srcset=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/11.png 672w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/11-300x300.png 300w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/11-100x100.png 100w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/11-600x600.png 600w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/11-150x150.png 150w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p># \u52a0\u8f7d\u6240\u9700\u7684\u5305 library(ggplot2) library(dplyr) # \u6784\u5efa\u6570\u636e\u6846 diseas [&hellip;]<\/p>\n","protected":false},"author":111,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-480","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=480"}],"version-history":[{"count":0,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/480\/revisions"}],"wp:attachment":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}