{"id":2315,"date":"2024-08-02T08:02:12","date_gmt":"2024-08-01T23:02:12","guid":{"rendered":"https:\/\/secondlife.lol\/?p=2315"},"modified":"2024-08-02T15:14:50","modified_gmt":"2024-08-02T06:14:50","slug":"rental-lease-renewal-termination-schedule-visual-r","status":"publish","type":"post","link":"https:\/\/secondlife.lol\/zh\/rental-lease-renewal-termination-schedule-visual-r\/","title":{"rendered":"\u65e0\u9700 Excel \u5373\u53ef\u521b\u5efa\u7518\u7279\u56fe\uff08R &amp; Lease Renewal \u7279\u8f91\uff09"},"content":{"rendered":"<p>\u4ec5\u4ece\u6587\u5b57\u4e0a\u8bb0\u5f55\u300a\u4f4f\u5b85\u79df\u8d41\u6cd5\u300b\u4e2d\u89c4\u5b9a\u7684\u7eed\u8ba2\u548c\u7ec8\u6b62\u65e5\u671f\u5e76\u975e\u6613\u4e8b\u3002 \u60a8\u53ef\u4ee5\u4f7f\u7528 Excel \u4e2d\u7684\u7518\u7279\u56fe\uff0c\u4f46\u8fd8\u6709\u4e00\u79cd\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\u3002\u53ea\u9700\u590d\u5236\u5e76\u7c98\u8d34\u7518\u7279\u56fe\u7684\u6e90\u4ee3\u7801\u5e76\u8fd0\u884c\u5373\u53ef\u3002<\/p>\n\n\n\n<p>\u5728\u672c\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 R \u6765\u53ef\u89c6\u5316\u79df\u7ea6\u7eed\u8ba2\u548c\u7ec8\u6b62\u65f6\u95f4\u8868\u3002 \u5728 2021 \u5e74 2 \u6708 3 \u65e5\u7b7e\u8ba2\u4e86\u4e3a\u671f\u4e24\u5e74\u7684\u79df\u7ea6\u540e\uff0c\u8be5\u516c\u53f8\u5c06\u4e8e <a href=\"https:\/\/bravilife.com\/tacit-renewal-jeonse-contract\/\" target=\"_blank\" rel=\"noopener\">\u9690\u6027\u5c55\u671f<\/a>\u6211\u4eec\u8fd8\u4e3a\u623f\u4e1c\u548c\u79df\u6237\u5404\u81ea\u53d1\u51fa\u4e0d\u7eed\u79df\u901a\u77e5\u7684\u65f6\u95f4\u521b\u5efa\u4e86\u4e00\u4e2a\u53ef\u89c6\u5316\u8868\u8ff0\uff0c\u4ee5\u4fbf\u60a8\u6e05\u695a\u5730\u4e86\u89e3\u91cd\u8981\u65e5\u671f\u3002<\/p>\n\n\n<style>.kb-image2315_4640db-9a .kb-image-has-overlay:after{opacity:0.3;}<\/style>\n<div class=\"wp-block-kadence-image kb-image2315_4640db-9a\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"600\" height=\"400\" src=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/08\/image-1-2-600x400.jpg\" alt=\"\uac04\ud2b8\ucc28\ud2b8 \uc5d1\uc140\uc5c6\uc774 \ub9cc\ub4dc\ub294 R \uc2dc\uac01\ud654 \uadf8\ub9bc\" class=\"kb-img wp-image-2331\" srcset=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/08\/image-1-2-600x400.jpg 600w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/08\/image-1-2-300x200.jpg 300w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/08\/image-1-2-768x512.jpg 768w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/08\/image-1-2.jpg 1200w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><figcaption>(\u4f7f\u7528 R \u521b\u5efa\u7518\u7279\u56fe\u7684\u7ed3\u679c\uff09<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u65e0\u9700 Excel \u5373\u53ef\u521b\u5efa\u7518\u7279\u56fe<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u60a8\u5e0c\u671b\u770b\u5230\u7684\u79df\u8d41\u65f6\u95f4\u8868<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>2021 \u5e74 2 \u6708 3 \u65e5\uff1a\u5408\u540c\u5f00\u59cb<\/li>\n\n\n\n<li>2023 \u5e74 2 \u6708 2 \u65e5\uff1a\u5408\u540c\u7ed3\u675f<\/li>\n\n\n\n<li>2022 \u5e74 8 \u6708 3 \u65e5\u81f3 2022 \u5e74 12 \u6708 2 \u65e5\uff1a\u623f\u4e1c\/\u79df\u6237\u5fc5\u987b\u53d1\u51fa\u4e0d\u7eed\u79df\u901a\u77e5\u7684\u65f6\u95f4<\/li>\n\n\n\n<li>2023 \u5e74 5 \u6708 1 \u65e5\uff1a\u9ed8\u793a\u7eed\u7ea6\u540e\u7684\u79df\u6237\u7ec8\u6b62\u901a\u77e5<\/li>\n\n\n\n<li>2023 \u5e74 8 \u6708 1 \u65e5\uff1a\u5408\u540c\u7ec8\u6b62\uff0c\u4fdd\u8bc1\u91d1\u9000\u8fd8<\/li>\n<\/ul>\n\n\n\n<p>\u5982\u679c\u60a8\u5728 2021 \u5e74 2 \u6708 3 \u65e5\u7b7e\u8ba2\u4e86\u4e3a\u671f 2 \u5e74\u7684\u5168\u7403\u79df\u7ea6\uff0c\u5982\u679c\u60a8\u6709\u6cd5\u5f8b\u8ba4\u53ef\u7684\u7406\u7531\uff0c\u623f\u4e1c\u53ef\u4ee5\u5728\u79df\u7ea6\u5230\u671f\u65e5\uff082023 \u5e74 2 \u6708 2 \u65e5\uff09\u524d\u7ec8\u6b62\u60a8\u7684\u79df\u7ea6\u3002 <strong>6 \u4e2a\u6708<\/strong>2022 \u5e74 8 \u6708 3 \u65e5\u6216\u4e4b\u524d\uff0c\u5408\u540c\u7ed3\u675f\u65e5\u671f <strong>2 \u4e2a\u6708<\/strong>\u5982\u679c\u623f\u4e1c\u548c\u79df\u6237\u56e0\u4e2a\u4eba\u539f\u56e0\u9700\u8981\u642c\u8fc1\uff0c\u5fc5\u987b\u5728 2022 \u5e74 12 \u6708 2 \u65e5\u81f3\u79df\u7ea6\u671f\u6ee1\u524d\u53d1\u51fa\u4e0d\u7eed\u79df\u901a\u77e5\u3002 <strong>2 \u4e2a\u6708<\/strong>\u60a8\u53ef\u5728 2022 \u5e74 12 \u6708 2 \u65e5\u524d\u53d1\u51fa\u4e0d\u7eed\u7ea6\u901a\u77e5\u3002<\/p>\n\n\n\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5047\u8bbe\u9ed8\u793a\u7eed\u7ea6\u5c06\u4e16\u754c\u8303\u56f4\u5185\u7684\u79df\u671f\u518d\u5ef6\u957f\u4e24\u5e74\uff0c\u5982\u679c\u79df\u6237\u5728 2023 \u5e74 5 \u6708 1 \u65e5\u53d1\u51fa\u9000\u79df\u901a\u77e5\uff0c\u623f\u4e1c\u5c31\u5fc5\u987b\u5728 2023 \u5e74 8 \u6708 1 \u65e5\uff0c\u5373\u6536\u5230\u901a\u77e5\u7684\u4e09\u4e2a\u6708\u540e\u9000\u8fd8\u62bc\u91d1\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u7528 R \u5c06\u8fd9\u4e2a\u590d\u6742\u7684\u65f6\u95f4\u8868\u53ef\u89c6\u5316\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u65e0\u9700 Excel \u5373\u53ef\u521b\u5efa\u7518\u7279\u56fe\u7684 R \u4ee3\u7801\u8bf4\u660e<\/h2>\n\n\n\n<p>\u9996\u5148\uff0c\u5b89\u88c5\u5e76\u52a0\u8f7d\u6240\u9700\u7684\u8f6f\u4ef6\u5305\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5982\u679c (!require(ggplot2)) install.packages(\"ggplot2\")\nif (!require(dplyr)) install.packages(\"dplyr\")\nlibrary(ggplot2)\nlibrary(dplyr)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u6570\u636e\u6846<\/h3>\n\n\n\n<p>\u4e3a\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u6846\u3002 \u4e3a\u6bcf\u4e2a\u65f6\u95f4\u6bb5\u4ee5\u53ca\u5f00\u59cb\u548c\u7ed3\u675f\u65e5\u671f\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u6846\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df &lt;- data.frame(\n  Task = c(&quot;Initial Contract Term&quot;, &quot;Landlord Notice Period&quot;, &quot;Tenant Notice Period&quot;\u3001\n           &quot;\u7eed\u7ea6\u5408\u540c\u671f\u9650&quot;\u3001&quot;\u901a\u77e5\u540e 3 \u4e2a\u6708&quot;)\u3001\n  Start = as.Date(c(&quot;2021-02-03&quot;, &quot;2022-08-03&quot;, &quot;2022-08-03&quot;\u3001\n                    &quot;2023-02-03&quot;, &quot;2023-05-01&quot;))),\n  End = as.Date(c(&quot;2023-02-02&quot;, &quot;2022-12-02&quot;, &quot;2022-12-02&quot;\u3001\n                  &quot;2025-02-02&quot;, &quot;2023-07-30&quot;))),\n  Section = c(&quot;\u521d\u59cb\u5408\u540c&quot;\u3001&quot;\u4e0d\u7eed\u7ea6\u901a\u77e5&quot;\u3001&quot;\u4e0d\u7eed\u7ea6\u901a\u77e5&quot;\u3001&quot;\u7eed\u7ea6\u5408\u540c&quot;\u3001&quot;\u4e0d\u7eed\u7ea6\u901a\u77e5&quot;)\n              &quot;\u7eed\u8ba2\u5408\u540c&quot;\u3001&quot;\u5408\u540c\u7ec8\u6b62&quot;)\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u91cd\u8981\u65e5\u671f\u6570\u636e\u6846<\/h3>\n\n\n\n<p>\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u91cd\u8981\u65e5\u671f\u7684\u6570\u636e\u6846\u3002\u4e0a\u9762\u521b\u5efa\u7684\u6570\u636e\u6846\u662f\u7528\u4e8e\u6846\u67b6\u76ee\u7684\uff0c\u5176\u4e2d\u7684\u65e5\u671f\u662f\u60a8\u5728\u56fe\u8868\u4e2d\u663e\u793a\u865a\u7ebf\u548c\u65e5\u671f\u6807\u7b7e\u6240\u9700\u8981\u7684\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>important_dates &lt;- as.Date(c(&quot;2021-02-03&quot;, &quot;2023-02-02&quot;, &quot;2022-08-03&quot;, &quot;2022-12-02&quot;\u3001\n                             &quot;2023-01-02&quot;, &quot;2023-02-03&quot;, &quot;2025-02-02&quot;,\n                             &quot;2023-05-01&quot;, &quot;2023-08-01&quot;)))\nimportant_dates &lt;- sort(important_dates)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6539\u8fdb\u65e5\u671f\u6807\u7b7e\u91cd\u65b0\u5b9a\u4f4d\u529f\u80fd<\/h3>\n\n\n\n<p>\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6765\u91cd\u65b0\u5b9a\u4f4d\u65e5\u671f\u6807\u7b7e\uff0c\u4f7f\u5b83\u4eec\u4e0d\u4f1a\u76f8\u4e92\u91cd\u53e0\u3002\u8fd9\u662f\u6700\u68d8\u624b\u7684\u90e8\u5206\uff0c\u56e0\u4e3a\u5982\u679c\u6211\u4eec\u8981\u663e\u793a\u7684\u65e5\u671f\u6807\u7b7e\u9760\u5f97\u592a\u8fd1\uff0c\u5b83\u4eec\u5c31\u4f1a\u91cd\u53e0\uff0c\u96be\u4ee5\u770b\u6e05\uff0c\u6240\u4ee5\u6211\u4eec\u8981\u5b9e\u73b0\u4e00\u4e2a\u51fd\u6570\uff0c\u68c0\u67e5\u76f8\u8ddd 7 \u5929\u4ee5\u5185\u7684\u65e5\u671f\uff0c\u5e76\u5c06\u5b83\u4eec\u4e0a\u4e0b\u5206\u5f00\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>adjust_label_position &lt;- function(dates) {\n  n &lt;- length(dates)\n  positions &lt;- rep(0, n)\n  last_position &lt;- 0\n  for (i in 2:n) {\n    if (as.numeric(dates[i] - dates[i-1]) &lt;= 7) { # \u68c0\u67e5 7 \u5929\u5185\u6700\u8fd1\u7684\u65e5\u671f\n      positions[i] &lt;- (last_position + 1) %% 2 # \u6839\u636e\u524d\u4e00\u4e2a\u4f4d\u7f6e\u4ea4\u66ff\u4e0a\u4e0b\u79fb\u52a8\n      last_position &lt;- positions[i]\n    } else {\n      last_position &lt;- 0\n    }\n  }\n  return(positions)\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8c03\u6574\u65e5\u671f\u6807\u7b7e\u4f4d\u7f6e<\/h3>\n\n\n\n<p>\u4f7f\u7528\u4e0a\u9762\u5b9a\u4e49\u7684\u529f\u80fd\u8c03\u6574\u65e5\u671f\u6807\u7b7e\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>label_positions &lt;- adjust_label_position(important_dates)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u65e5\u671f\u6807\u7b7e\u6570\u636e\u6846<\/h3>\n\n\n\n<p>\u521b\u5efa\u4e00\u4e2a\u5e26\u6709\u6807\u7b7e\u4f4d\u7f6e\u7684\u6570\u636e\u6846\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>date_labels &lt;- data.frame(\n  x = important_dates\u3001\n  y = length(df$Task) + 1\u3001\n  label = format(important_dates, &quot;%Y-%m-%d&quot;)\u3001\n  \u4f4d\u7f6e = label_positions\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u548c\u8f93\u51fa\u7ed8\u56fe\uff08\u56fe\u8868\uff09<\/h3>\n\n\n\n<p>\u4f7f\u7528 ggplot2 \u751f\u6210\u56fe\u8868\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p &lt;- ggplot() +\n  geom_segment(data = df, aes(x = Start, xend = End, y = Task, yend = Task, color = Section), size = 8) +\n  geom_vline(xintercept = important_dates, linetype = &quot;dashed&quot;, color = &quot;darkgray&quot;) +\n  geom_text(data = date_labels\u3001\n            aes(x = x, y = y + ifelse(position == 0, -0.5, 0.5), label = label)\u3001\n            angle = 90, hjust = ifelse(date_labels$position == 0, 1, 0), vjust = 0.5, size = 3) +\n  scale_x_date(date_labels = &quot;%YYear %mmonth&quot;, date_breaks = &quot;3 months&quot;) +\n  scale_y_discrete(limits = c(df$Task, &quot;&quot;, &quot;&quot;)) +\n  theme_minimal() +\n  labs(title = &quot;\u79df\u7ea6\u7eed\u8ba2\u548c\u7ec8\u6b62\u65f6\u95f4\u8868\uff08\u793a\u4f8b\uff09&quot;\u3001\n       x = &quot;\u65e5\u671f&quot;, y = &quot;&quot;) +\n  theme(legend.position = &quot;bottom&quot;\u3001\n        plot.title = element_text(hjust = 0.5, size = 16)\u3001\n        axis.text.x = element_text(angle = 45, hjust = 1)\u3001\n        panel.grid.minor = element_blank())\n\n\u6253\u5370\uff08p\uff09<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4fdd\u5b58\u4e3a PNG \u683c\u5f0f<\/h3>\n\n\n\n<p>\u5c06\u751f\u6210\u7684\u7ed8\u56fe\u4fdd\u5b58\u4e3a PNG \u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ggsave(\"lease_renewal_process_with_alternating_labels.png\", plot = p, width = 15, height = 10, dpi = 300)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b8c\u6574\u6e90\u4ee3\u7801<\/h2>\n\n\n\n<p>\u4e0b\u9762\u662f\u4e0a\u8ff0\u5b8c\u6574\u7684\u6e90\u4ee3\u7801\u3002\u5c06\u5176\u7c98\u8d34\u5e76\u8fd0\u884c\uff0c\u5373\u53ef\u770b\u5230\u672c\u5e16\u9876\u90e8\u7684\u56fe\u7247\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \ud544\uc694\ud55c \ud328\ud0a4\uc9c0 \uc124\uce58 \ubc0f \ub85c\ub4dc\nif (!require(ggplot2)) install.packages(\"ggplot2\")  # ggplot2 \ud328\ud0a4\uc9c0\uac00 \uc5c6\uc73c\uba74 \uc124\uce58\nif (!require(dplyr)) install.packages(\"dplyr\")      # dplyr \ud328\ud0a4\uc9c0\uac00 \uc5c6\uc73c\uba74 \uc124\uce58\nlibrary(ggplot2)  # ggplot2 \ud328\ud0a4\uc9c0 \ub85c\ub4dc (\uadf8\ub798\ud504 \uc0dd\uc131\uc6a9)\nlibrary(dplyr)    # dplyr \ud328\ud0a4\uc9c0 \ub85c\ub4dc (\ub370\uc774\ud130 \uc870\uc791\uc6a9)\n\n# \ub370\uc774\ud130 \ud504\ub808\uc784 \uc0dd\uc131\ndf &lt;- data.frame(\n    Task = c(\"\ucd08\uae30 \uacc4\uc57d \uae30\uac04\", \"\uc9d1\uc8fc\uc778 \ud1b5\uc9c0 \uac00\ub2a5 \uae30\uac04\", \"\uc138\uc785\uc790 \ud1b5\uc9c0 \uac00\ub2a5 \uae30\uac04\",\"\uac31\uc2e0 \uacc4\uc57d \uae30\uac04\", \"\ud1b5\ubcf4 \ud6c4 3\uac1c\uc6d4\"),  # \uac01 \uae30\uac04\uc758 \uc774\ub984\n    Start = as.Date(c(\"2021-02-03\", \"2022-08-03\", \"2022-08-03\",\"2023-02-03\", \"2023-05-01\")),  # \uac01 \uae30\uac04\uc758 \uc2dc\uc791\uc77c\n    End = as.Date(c(\"2023-02-02\", \"2022-12-02\", \"2022-12-02\",\"2025-02-02\", \"2023-07-30\")),    # \uac01 \uae30\uac04\uc758 \uc885\ub8cc\uc77c\n    Section = c(\"\ucd08\uae30 \uacc4\uc57d\", \"\uac31\uc2e0 \uac70\uc808 \ud1b5\uc9c0\", \"\uac31\uc2e0 \uac70\uc808 \ud1b5\uc9c0\",\"\uac31\uc2e0 \uacc4\uc57d\", \"\uacc4\uc57d \ud574\uc9c0\")  # \uac01 \uae30\uac04\uc758 \ubd84\ub958\n)\n\n# \uc911\uc694\ud55c \ub0a0\uc9dc \ub370\uc774\ud130 \ud504\ub808\uc784 \uc0dd\uc131\nimportant_dates &lt;- as.Date(c(\"2021-02-03\", \"2023-02-02\", \"2022-08-03\", \"2022-12-02\",\n                             \"2023-01-02\", \"2023-02-03\", \"2025-02-02\",\n                             \"2023-05-01\", \"2023-08-01\"))  # \uc911\uc694\ud55c \ub0a0\uc9dc\ub4e4\uc744 \ubca1\ud130\ub85c \uc815\uc758\nimportant_dates &lt;- sort(important_dates)  # \ub0a0\uc9dc\ub97c \uc624\ub984\ucc28\uc21c\uc73c\ub85c \uc815\ub82c\n\n# \ub0a0\uc9dc \ub808\uc774\ube14 \uc704\uce58 \uc870\uc815 \ud568\uc218 \uac1c\uc120\nadjust_label_position &lt;- function(dates) {\n    n &lt;- length(dates)\n    positions &lt;- rep(0, n)  # \ubaa8\ub4e0 \uc704\uce58\ub97c 0\uc73c\ub85c \ucd08\uae30\ud654\n    last_position &lt;- 0\n    for (i in 2:n) {\n        if (as.numeric(dates&#91;i] - dates&#91;i-1]) &lt;= 7) {  # 7\uc77c \uc774\ub0b4\uc758 \uadfc\uc811\ud55c \ub0a0\uc9dc \ud655\uc778\n            positions&#91;i] &lt;- (last_position + 1) %% 2     # \uc774\uc804 \uc704\uce58\uc5d0 \ub530\ub77c \uc0c1\ud558 \uad50\ub300 (0 \ub610\ub294 1)\n            last_position &lt;- positions&#91;i]\n        } else {\n            last_position &lt;- 0\n        }\n    }\n    return(positions)\n}\n\n# \ub0a0\uc9dc \ub808\uc774\ube14 \uc704\uce58 \uc870\uc815\nlabel_positions &lt;- adjust_label_position(important_dates)\n\n# \ub0a0\uc9dc \ub808\uc774\ube14 \ub370\uc774\ud130 \ud504\ub808\uc784 \uc0dd\uc131\ndate_labels &lt;- data.frame(\n    x = important_dates,  # x\ucd95 \uc704\uce58 (\ub0a0\uc9dc)\n    y = length(df$Task) + 1,  # y\ucd95 \uc704\uce58 (\ubaa8\ub4e0 Task \uc704\uc5d0 \uc704\uce58)\n    label = format(important_dates, \"%Y-%m-%d\"),  # \ub808\uc774\ube14 \ud14d\uc2a4\ud2b8 (\ub0a0\uc9dc \ud615\uc2dd)\n    position = label_positions  # \ub808\uc774\ube14\uc758 \uc0c1\ud558 \uc704\uce58 (0 \ub610\ub294 1)\n)\n\n# \ud50c\ub86f \uc0dd\uc131\np &lt;- ggplot() +\n    geom_segment(data = df, aes(x = Start, xend = End, y = Task, yend = Task, color = Section), size = 8) +\n    # \uac01 Task\uc5d0 \ub300\ud55c \uae30\uac04\uc744 \ub098\ud0c0\ub0b4\ub294 \uc120\ubd84. x: \uc2dc\uc791\uc77c, xend: \uc885\ub8cc\uc77c, y: Task \uc774\ub984, color: Section\uc73c\ub85c \uc0c9\uc0c1 \uad6c\ubd84\n    \n    geom_vline(xintercept = important_dates, linetype = \"dashed\", color = \"darkgray\") +\n    # \uc911\uc694\ud55c \ub0a0\uc9dc\uc5d0 \uc218\uc9c1\uc120 \ucd94\uac00. linetype: \uc810\uc120, color: \uc9c4\ud55c \ud68c\uc0c9\n    \n    geom_text(data = date_labels,\n              aes(x = x, y = y + ifelse(position == 0, -0.5, 0.5), label = label),\n              angle = 90, hjust = ifelse(date_labels$position == 0, 1, 0), vjust = 0.5, size = 3) +\n    # \ub0a0\uc9dc \ub808\uc774\ube14 \ucd94\uac00. x: \ub0a0\uc9dc \uc704\uce58, y: Task \uc704 \ub610\ub294 \uc544\ub798, label: \ub0a0\uc9dc \ud14d\uc2a4\ud2b8\n    # angle: 90\ub3c4 \ud68c\uc804, hjust &amp; vjust: \ub808\uc774\ube14 \uc815\ub82c, size: \uae00\uc790 \ud06c\uae30\n    \n    scale_x_date(date_labels = \"%Y\ub144 %m\uc6d4\", date_breaks = \"3 months\") +\n    # x\ucd95 \ub0a0\uc9dc \ud615\uc2dd \uc124\uc815. date_labels: \ub144\uc6d4 \ud45c\uc2dc \ud615\uc2dd, date_breaks: 3\uac1c\uc6d4 \uac04\uaca9\uc73c\ub85c \ub208\uae08 \ud45c\uc2dc\n    \n    scale_y_discrete(limits = c(df$Task, \"\", \"\")) +\n    # y\ucd95 \uc124\uc815. limits: Task \uc774\ub984\ub4e4\uacfc \ucd94\uac00 \uc5ec\ubc31 \uc124\uc815\n    \n    theme_minimal() +  # \ucd5c\uc18c\ud55c\uc758 \ud14c\ub9c8 \uc801\uc6a9\n    labs(title = \"\uc784\ub300\ucc28 \uacc4\uc57d \uac31\uc2e0 \ubc0f \ud574\uc9c0 \uc2a4\ucf00\uc974 (\uc608\uc2dc)\",\n         x = \"\ub0a0\uc9dc\", y = \"\") +  # \uadf8\ub798\ud504 \uc81c\ubaa9, x\ucd95 \ub808\uc774\ube14 \uc124\uc815\n    theme(legend.position = \"bottom\",  # \ubc94\ub840 \uc704\uce58\ub97c \uc544\ub798\ub85c \uc124\uc815\n          plot.title = element_text(hjust = 0.5, size = 16),  # \uc81c\ubaa9 \uc911\uc559 \uc815\ub82c \ubc0f \ud06c\uae30 \uc124\uc815\n          axis.text.x = element_text(angle = 45, hjust = 1),  # x\ucd95 \ub808\uc774\ube14 45\ub3c4 \ud68c\uc804\n          panel.grid.minor = element_blank())  # \uc791\uc740 \uaca9\uc790\uc120 \uc81c\uac70\n\n# \ud50c\ub86f \ucd9c\ub825\nprint(p)\n\n# PNG \ud615\uc2dd\uc73c\ub85c \uc800\uc7a5\nggsave(\"lease_renewal_process_with_alternating_labels.png\", plot = p, width = 15, height = 10, dpi = 300)\n# \ud30c\uc77c\uba85, \ud50c\ub86f \uac1d\uccb4, \ub108\ube44, \ub192\uc774, \ud574\uc0c1\ub3c4 \uc124\uc815<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ec4\u7ec7\u8d77\u6765<\/h2>\n\n\n\n<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u4f7f\u7528 R \u6765\u53ef\u89c6\u5316\u79df\u7ea6\u7eed\u7b7e\u548c\u7ec8\u6b62\u65f6\u95f4\u8868\u3002 \u5c06\u590d\u6742\u7684\u5408\u540c\u65f6\u95f4\u8868\u8868\u793a\u4e3a\u53ef\u89c6\u5316\u65f6\u95f4\u8868\u8868\uff0c\u53ef\u4ee5\u8ba9\u91cd\u8981\u65e5\u671f\u4e00\u76ee\u4e86\u7136\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u6211\u5b89\u88c5\u4e86\u5fc5\u8981\u7684\u8f6f\u4ef6\u5305\uff0c\u51c6\u5907\u4e86\u6570\u636e\uff0c\u5e76\u7f16\u5199\u4e86\u4e00\u4e2a\u8c03\u6574\u65e5\u671f\u6807\u7b7e\u7684\u51fd\u6570\uff0c\u4f7f\u5b83\u4eec\u4e0d\u4f1a\u91cd\u53e0\u3002 \u7136\u540e\uff0c\u6211\u89e3\u91ca\u4e86\u4f7f\u7528 ggplot2 \u521b\u5efa\u79df\u8d41\u671f\u9650\u548c\u91cd\u8981\u65e5\u671f\u7684\u53ef\u89c6\u5316\u56fe\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u4e3a PNG \u6587\u4ef6\u7684\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>\u8fd9\u79cd\u53ef\u89c6\u5316\u6280\u672f\u4e0d\u4ec5\u5bf9\u79df\u8d41\u534f\u8bae\u5f88\u6709\u5e2e\u52a9\uff0c\u5bf9\u5404\u79cd\u65e5\u7a0b\u5b89\u6392\u548c\u9879\u76ee\u89c4\u5212\u4e5f\u5f88\u6709\u5e2e\u52a9\u3002\u5728\u7ee7\u7eed\u63a2\u7d22\u4e0d\u540c\u7684\u6570\u636e\u53ef\u89c6\u5316\u6280\u672f\u65f6\uff0c\u8bf7\u7ec3\u4e60\u6e05\u6670\u5730\u8868\u8fbe\u6570\u636e\u7684\u542b\u4e49\u3002\u6b64\u5916\uff0c\u6211\u4eec\u5e0c\u671b\u4f60\u80fd\u901a\u8fc7\u53ef\u89c6\u5316\u6570\u636e\u57f9\u517b\u505a\u51fa\u66f4\u597d\u51b3\u7b56\u7684\u80fd\u529b\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u4ece\u6587\u672c\u4e2d\u5f88\u96be\u7406\u89e3\u300a\u4f4f\u5b85\u79df\u8d41\u6cd5\u300b\u4e2d\u7684\u66f4\u65b0\u548c\u7ec8\u6b62\u65e5\u671f...<\/p>","protected":false},"author":3,"featured_media":2320,"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":[176,174,187,186,164,185],"class_list":["post-2315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r-coding","tag-ggplot2","tag-r-","tag-187","tag-186","tag-164","tag-185"],"taxonomy_info":{"category":[{"value":6,"label":"\uc54c(R)"}],"post_tag":[{"value":176,"label":"ggplot2"},{"value":174,"label":"R \ud504\ub85c\uadf8\ub798\ubc0d"},{"value":187,"label":"\uac04\ud2b8\ucc28\ud2b8"},{"value":186,"label":"\uac31\uc2e0 \uac70\uc808 \ud1b5\uc9c0"},{"value":164,"label":"\ub370\uc774\ud130 \uc2dc\uac01\ud654"},{"value":185,"label":"\uc784\ub300\ucc28 \uacc4\uc57d"}]},"featured_image_src_large":["https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/08\/\uac04\ud2b8\ucc28\ud2b8-\uc5d1\uc140\uc5c6\uc774-\ub9cc\ub4e4\uae30-thumbnail-600x600.jpg",600,600,true],"author_info":{"display_name":"TERE","author_link":"https:\/\/secondlife.lol\/zh\/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":176,"name":"ggplot2","slug":"ggplot2","term_group":0,"term_taxonomy_id":176,"taxonomy":"post_tag","description":"","parent":0,"count":15,"filter":"raw"},{"term_id":174,"name":"R \ud504\ub85c\uadf8\ub798\ubc0d","slug":"r-%ed%94%84%eb%a1%9c%ea%b7%b8%eb%9e%98%eb%b0%8d","term_group":0,"term_taxonomy_id":174,"taxonomy":"post_tag","description":"","parent":0,"count":15,"filter":"raw"},{"term_id":187,"name":"\uac04\ud2b8\ucc28\ud2b8","slug":"%ea%b0%84%ed%8a%b8%ec%b0%a8%ed%8a%b8","term_group":0,"term_taxonomy_id":187,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":186,"name":"\uac31\uc2e0 \uac70\uc808 \ud1b5\uc9c0","slug":"%ea%b0%b1%ec%8b%a0-%ea%b1%b0%ec%a0%88-%ed%86%b5%ec%a7%80","term_group":0,"term_taxonomy_id":186,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":164,"name":"\ub370\uc774\ud130 \uc2dc\uac01\ud654","slug":"%eb%8d%b0%ec%9d%b4%ed%84%b0-%ec%8b%9c%ea%b0%81%ed%99%94","term_group":0,"term_taxonomy_id":164,"taxonomy":"post_tag","description":"","parent":0,"count":52,"filter":"raw"},{"term_id":185,"name":"\uc784\ub300\ucc28 \uacc4\uc57d","slug":"%ec%9e%84%eb%8c%80%ec%b0%a8-%ea%b3%84%ec%95%bd","term_group":0,"term_taxonomy_id":185,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts\/2315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/comments?post=2315"}],"version-history":[{"count":9,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts\/2315\/revisions"}],"predecessor-version":[{"id":2333,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts\/2315\/revisions\/2333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/media\/2320"}],"wp:attachment":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/media?parent=2315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/categories?post=2315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/tags?post=2315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}