{"id":4159,"date":"2024-12-24T21:24:27","date_gmt":"2024-12-24T12:24:27","guid":{"rendered":"https:\/\/secondlife.lol\/?p=4159"},"modified":"2024-12-27T20:53:48","modified_gmt":"2024-12-27T11:53:48","slug":"radar-chart-r","status":"publish","type":"post","link":"https:\/\/secondlife.lol\/en\/radar-chart-r\/","title":{"rendered":"Radar Charts: A Guide to Data Visualization with R"},"content":{"rendered":"<style>.kb-image4159_d57596-4a .kb-image-has-overlay:after{opacity:0.3;border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;}.kb-image4159_d57596-4a img.kb-img, .kb-image4159_d57596-4a .kb-img img{border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}<\/style>\n<div class=\"wp-block-kadence-image kb-image4159_d57596-4a\"><figure class=\"aligncenter size-medium_large\"><img decoding=\"async\" width=\"768\" height=\"569\" src=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-35-768x569.jpg\" alt=\"\ubc29\uc0ac\ud615 \ucc28\ud2b8 - R \ub370\uc774\ud130 \uc2dc\uac01\ud654\" class=\"kb-img wp-image-4164\" srcset=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-35-768x569.jpg 768w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-35-300x222.jpg 300w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-35-600x445.jpg 600w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-35-16x12.jpg 16w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-35.jpg 1013w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><figcaption>(R Data Visualization)<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">When you want to compare multiple variables, analyzing data with just numbers can often be overwhelming. This is where radar charts can be an excellent choice. Radar charts utilize multiple axes to visually represent data, and are especially useful when comparing characteristics or drawing patterns between different groups.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, we'll use the <a href=\"https:\/\/www.r-project.org\/\" target=\"_blank\" rel=\"noopener\">R<\/a>The <strong>FMSB Package<\/strong>to utilize the <strong>How to create a radar chart<\/strong>and how to effectively analyze and utilize data through radar charts.<\/p>\n\n\n<style>.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap{padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-right:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);padding-left:var(--global-kb-spacing-sm, 1.5rem);border-top:3px solid var(--global-palette2, #2B6CB0);border-right:3px solid var(--global-palette2, #2B6CB0);border-bottom:3px solid var(--global-palette2, #2B6CB0);border-left:3px solid var(--global-palette2, #2B6CB0);border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title-wrap{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title-wrap{color:var(--global-palette2, #2B6CB0);}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title{color:var(--global-palette2, #2B6CB0);font-size:28px;font-weight:regular;font-style:normal;}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap .kb-table-of-content-list{color:var(--global-palette1, #3182CE);line-height:2em;font-weight:regular;font-style:normal;margin-top:var(--global-kb-spacing-sm, 1.5rem);margin-right:0px;margin-bottom:0px;margin-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap .kb-table-of-content-list .kb-table-of-contents__entry:hover{color:var(--global-palette6, #718096);}@media all and (max-width: 1024px){.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap{border-top:3px solid var(--global-palette2, #2B6CB0);border-right:3px solid var(--global-palette2, #2B6CB0);border-bottom:3px solid var(--global-palette2, #2B6CB0);border-left:3px solid var(--global-palette2, #2B6CB0);}}@media all and (max-width: 1024px){.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title{font-size:28px;}}@media all and (max-width: 767px){.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap{border-top:3px solid var(--global-palette2, #2B6CB0);border-right:3px solid var(--global-palette2, #2B6CB0);border-bottom:3px solid var(--global-palette2, #2B6CB0);border-left:3px solid var(--global-palette2, #2B6CB0);}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title{font-size:28px;}}<\/style>\n\n\n<h2 class=\"wp-block-heading\">What is a radar chart?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A radar chart is a graph that visualizes R data in the form of polygons along multiple axes.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose of use<\/strong>: Relative comparisons or pattern analysis of multiple items.<\/li>\n\n\n\n<li><strong>Features<\/strong>\n<ul class=\"wp-block-list\">\n<li>Each axis represents a variable (attribute).<\/li>\n\n\n\n<li>Closer to the end of the axis means a higher value for that variable.<\/li>\n\n\n\n<li>You can overlay multiple data sets to make comparisons between groups.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Radar charts can be used in a variety of areas, including analyzing survey results, comparing products, evaluating team performance, and more.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">R Data Visualization: Leveraging the fmsb package<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Code blocks<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Below is the code for the R data visualization.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Install and load the # fmsb package\nif (!requireNamespace(\"fmsb\", quietly = TRUE)) {\n  install.packages(\"fmsb\") install # package if it doesn't exist\n}\nlibrary(fmsb) load # package\n\n# Data Generation and Dataframe Conversion\n# Evaluation score for each item\nres &lt;- c(3, 4, 5, 3, 6, 5, 7, 4, 6, 7, 5, 5, 2, 3, 3, 3, 3)\nmat &lt;- matrix(res, byrow = TRUE, ncol = 8)\ndf &lt;- as.data.frame(mat)\ncolnames(df) &lt;- c(&quot;Performance&quot;, &quot;Stability&quot;, &quot;Usability&quot;, &quot;Durability&quot;,\n                  &quot;Approachability&quot;, &quot;Differentiation&quot;, &quot;Reputation&quot;, &quot;Pride&quot;)\n\nAdd # max and min values (to set the axis range of the radar chart)\ndf &lt;- rbind(rep(7, 8), rep(1, 8), df)\n\nDefine the # color palette\nlibrary(scales)\nfill_colors &lt;- alpha(c(&quot;#FF6347&quot;, &quot;#4682B4&quot;), 0.4)\n\nDraw the # radar chart\nradarchart(\n  df,\n  axistype = 1,\n  pcol = c(&quot;#FF6347&quot;, &quot;#4682B4&quot;),\n  pfcol = fill_colors,\n  plwd = 2,\n  cglcol = &quot;grey&quot;,\n  cglty = 1,\n  cglwd = 0.8,\n  axislabcol = &quot;black&quot;,\n  vlcex = 1.2\n)\n\nAdd a title for the #\ntitle(main = &quot;Radar Chart: Product Comparison&quot;,\n      col.main = &quot;black&quot;,\n      font.main = 2,\n      cex.main = 1.5)\n\nAdd the # legend\nlegend(\n  x = 1, y = 0.8,\n  legend = c(&quot;Product A&quot;, &quot;Product B&quot;),\n  col = c(&quot;#FF6347&quot;, &quot;#4682B4&quot;),\n  pch = 15,\n  pt.cex = 2,\n  cex = 1.2,\n  bty = &quot;n&quot;\n)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Code commentary<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">1. Install and load the FMSB package<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>if (!requireNamespace(\"fmsb\", quietly = TRUE)) {\n  install.packages(\"fmsb\")\n}\nlibrary(fmsb)<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>requireNamespace()<\/code>using the <code>fmsb<\/code> Check to see if the package is installed, and if not, install and load it.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. generate data<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>res &lt;- c(3, 4, 5, 3, 6, 5, 7, 4, 6, 7, 5, 5, 2, 3, 3, 3, 3)\nmat &lt;- matrix(res, byrow = TRUE, ncol = 8)\ndf &lt;- as.data.frame(mat)<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create evaluation scores as vectors (<code>res<\/code>), and then converted to a matrix (<code>matrix<\/code>) and converted to a dataframe (<code>as.data.frame<\/code>).<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. Set the axis range<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>df &lt;- rbind(rep(7, 8), rep(1, 8), df)<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add a maximum value (7) and a minimum value (1) to each axis to define the range of the radar chart.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. style the radar chart<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>radarchart(\n  df,\n  axistype = 1,\n  pcol = c(\"#FF6347\", \"#4682B4\"),\n  pfcol = fill_colors,\n  plwd = 2,\n  cglcol = \"grey\",\n  cglty = 1,\n  cglwd = 0.8,\n  axislabcol = \"black\",\n  vlcex = 1.2\n)<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>axistype<\/code>: Set axis style.<\/li>\n\n\n\n<li><code>pcol<\/code>: Color the data lines.<\/li>\n\n\n\n<li><code>pfcol<\/code>: Set the translucent color of the data area.<\/li>\n\n\n\n<li><code>cglcol<\/code>: Set the color of the grid lines to gray.<\/li>\n\n\n\n<li><code>vlcex<\/code>: Resize axis labels.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5. add a legend and title<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>title(main = \"Radar Chart: Product Comparison\")\nlegend(x = 1, y = 0.8, legend = c(\"Product A\", \"Product B\"), col = c(\"#FF6347\", \"#4682B4\"))<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add titles and legends to make your graphs more intuitive.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Advantages of radar charts<\/strong><\/h2>\n\n\n<style>.kb-image4159_280fc7-58 .kb-image-has-overlay:after{opacity:0.3;border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;}.kb-image4159_280fc7-58 img.kb-img, .kb-image4159_280fc7-58 .kb-img img{border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}<\/style>\n<div class=\"wp-block-kadence-image kb-image4159_280fc7-58\"><figure class=\"aligncenter size-medium_large\"><img decoding=\"async\" width=\"768\" height=\"436\" src=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-36-768x436.jpg\" alt=\"\ub808\uc774\ub354 \ucc28\ud2b8 \uc7a5\uc810\" class=\"kb-img wp-image-4166\" srcset=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-36-768x436.jpg 768w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-36-300x170.jpg 300w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-36-600x341.jpg 600w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-36-18x10.jpg 18w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/image-1-36.jpg 1200w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">1. compare data<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Optimized for multidimensional data analysis<\/strong><br>Radar charts provide a visual representation of multiple attributes on one screen, allowing you to intuitively compare values between each item.\n<ul class=\"wp-block-list\">\n<li>For example, you can simultaneously compare a product's performance, reliability, and price competitiveness to quickly identify where it excels and where it falls short.<\/li>\n\n\n\n<li>At a glance, you can see how the characteristics of a particular group differ from other groups.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. Discover patterns<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Identify the strengths and weaknesses of your data<\/strong><br>The radial structure allows you to see scalability from the center of your data, giving you a clear view of your strengths and weaknesses.\n<ul class=\"wp-block-list\">\n<li>Strengths: Values are displayed near the end of the axis, making them easy to see.<\/li>\n\n\n\n<li>Weaknesses: Values close to the center of the axis, which are clearly visible.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Detect trends and anomalies<\/strong><br>With multiple data sets overlaid, you can discover groups with similar patterns, or visually detect outliers where certain data deviates from the pattern.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. applicability<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Wide range of applications<\/strong><br>Radar charts are extremely useful for comparing data and analyzing patterns, and have a wide range of applications, including\n<ul class=\"wp-block-list\">\n<li><strong>Compare products<\/strong>Comparing key characteristics between competing products to inform consumer or marketing strategy.<\/li>\n\n\n\n<li><strong>Analyzing surveys<\/strong>Visualize survey data to analyze respondents' preferences or satisfaction.<\/li>\n\n\n\n<li><strong>Evaluate team performance<\/strong>Visually identify strengths and areas for improvement by comparing the performance of individual team members or across departments.<\/li>\n\n\n\n<li><strong>Decision support<\/strong>Analyzing the strengths and weaknesses of multiple alternatives to arrive at an optimal choice.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Enhance visual communication<\/strong><br>Communicating information through visual charts, rather than simply listing data as numbers, greatly improves communication efficiency.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. aesthetic and intuitive presentation<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Visually appealing<\/strong><br>Radar charts provide beautiful, modern visualizations that look like infographics and are highly readable in presentations and reports.<\/li>\n\n\n\n<li><strong>User-friendly<\/strong><br>It's a great tool for communicating complex data because the structure is easy to understand for those new to the data.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Finalize<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, we looked at the concept of radar charts and how to implement them with R. Radar charts are a powerful tool for intuitively showing patterns and relationships in your data. Modify your own data, tweak the styling, and create your own radar charts!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For reference, here's a visualization of Korea's painful history and the ongoing impeachment of the president in December 2024, along with past cases. In the spirit of not repeating history, I wrote it once. Impeachment history visualized using radar charts! <a href=\"https:\/\/secondlife.lol\/en\/korean-president-impeachment-analysis\/\" data-type=\"post\" data-id=\"3990\">Analyzing the impeachment of South Korea's president: R data visualization and historical lessons<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>When you want to compare multiple variables, analyzing data with numbers alone is an easy way to...<\/p>","protected":false},"author":3,"featured_media":4227,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[300,39,177,658],"class_list":["post-4159","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r-coding","tag-r-","tag-rstudio","tag-177","tag-658"],"taxonomy_info":{"category":[{"value":6,"label":"\uc54c(R)"}],"post_tag":[{"value":300,"label":"R \uc2dc\uac01\ud654"},{"value":39,"label":"RStudio"},{"value":177,"label":"\ub370\uc774\ud130 \ubd84\uc11d"},{"value":658,"label":"\ub808\uc774\ub354 \ucc28\ud2b8"}]},"featured_image_src_large":["https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/12\/\ubc29\uc0ac\ud615-\ucc28\ud2b8-\ud3ec\uc2a4\ud2b8-\uc378\ub124\uc77c-600x600.jpg",600,600,true],"author_info":{"display_name":"TERE","author_link":"https:\/\/secondlife.lol\/en\/author\/tere\/"},"comment_info":0,"category_info":[{"term_id":6,"name":"\uc54c(R)","slug":"r-coding","term_group":0,"term_taxonomy_id":6,"taxonomy":"category","description":"","parent":20,"count":61,"filter":"raw","cat_ID":6,"category_count":61,"category_description":"","cat_name":"\uc54c(R)","category_nicename":"r-coding","category_parent":20}],"tag_info":[{"term_id":300,"name":"R \uc2dc\uac01\ud654","slug":"r-%ec%8b%9c%ea%b0%81%ed%99%94","term_group":0,"term_taxonomy_id":300,"taxonomy":"post_tag","description":"","parent":0,"count":12,"filter":"raw"},{"term_id":39,"name":"RStudio","slug":"rstudio","term_group":0,"term_taxonomy_id":39,"taxonomy":"post_tag","description":"","parent":0,"count":9,"filter":"raw"},{"term_id":177,"name":"\ub370\uc774\ud130 \ubd84\uc11d","slug":"%eb%8d%b0%ec%9d%b4%ed%84%b0-%eb%b6%84%ec%84%9d","term_group":0,"term_taxonomy_id":177,"taxonomy":"post_tag","description":"","parent":0,"count":36,"filter":"raw"},{"term_id":658,"name":"\ub808\uc774\ub354 \ucc28\ud2b8","slug":"%eb%a0%88%ec%9d%b4%eb%8d%94-%ec%b0%a8%ed%8a%b8","term_group":0,"term_taxonomy_id":658,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/posts\/4159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/comments?post=4159"}],"version-history":[{"count":7,"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/posts\/4159\/revisions"}],"predecessor-version":[{"id":4169,"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/posts\/4159\/revisions\/4169"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/media\/4227"}],"wp:attachment":[{"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/media?parent=4159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/categories?post=4159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/secondlife.lol\/en\/wp-json\/wp\/v2\/tags?post=4159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}