{"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\/ja\/rental-lease-renewal-termination-schedule-visual-r\/","title":{"rendered":"\u30a8\u30af\u30bb\u30eb\u306a\u3057\u3067\u30ac\u30f3\u30c8\u30c1\u30e3\u30fc\u30c8\u4f5c\u6210(feat. R &amp; \u8cc3\u8cb8\u501f\u5951\u7d04\u66f4\u65b0)"},"content":{"rendered":"<p>\u4f4f\u5b85\u8cc3\u8cb8\u501f\u4fdd\u8b77\u6cd5\u3067\u5b9a\u3081\u3066\u3044\u308b\u5951\u7d04\u66f4\u65b0\u3068\u89e3\u7d04\u306b\u95a2\u3059\u308b\u65e5\u4ed8\u3092\u30c6\u30ad\u30b9\u30c8\u3060\u3051\u3067\u628a\u63e1\u3059\u308b\u306e\u306f\u5bb9\u6613\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 \u30ac\u30f3\u30c8\u30c1\u30e3\u30fc\u30c8\u30a8\u30af\u30bb\u30eb\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u3082\u3063\u3068\u7c21\u5358\u306a\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\u30ac\u30f3\u30c8\u30c1\u30e3\u30fc\u30c8\u4f5c\u6210\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\uff06\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001R\u3092\u4f7f\u7528\u3057\u3066\u8cc3\u8cb8\u501f\u5951\u7d04\u306e\u66f4\u65b0\u3068\u89e3\u7d04\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3092\u8996\u899a\u5316\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002 2021\u5e742\u67083\u65e5\u306b2\u5e74\u5951\u7d04\u3092\u7de0\u7d50\u3057\u305f\u5f8c\u30012021\u5e742\u67083\u65e5 <a href=\"https:\/\/bravilife.com\/tacit-renewal-jeonse-contract\/\" target=\"_blank\" rel=\"noopener\">\u9ed9\u793a\u7684\u66f4\u65b0<\/a>\u3067\u5951\u7d04\u304c\u5ef6\u9577\u3055\u308c\u305f\u5834\u5408\u3092\u60f3\u5b9a\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u3055\u3089\u306b\u3001\u5bb6\u4e3b\u3068\u501f\u4e3b\u304c\u305d\u308c\u305e\u308c\u3069\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u66f4\u65b0\u62d2\u5426\u306e\u901a\u77e5\u3092\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304b\u3092\u8996\u899a\u7684\u306b\u8868\u793a\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u3053\u306e\u8a18\u4e8b\u3092\u898b\u308c\u3070\u3001\u91cd\u8981\u306a\u65e5\u4ed8\u3092\u660e\u78ba\u306b\u628a\u63e1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306f\u305a\u3067\u3059\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>( R\u3092\u5229\u7528\u3057\u3066\u30ac\u30f3\u30c8\u30c1\u30e3\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u305f\u7d50\u679c )<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a8\u30af\u30bb\u30eb\u306a\u3057\u3067\u30ac\u30f3\u30c8\u30c1\u30e3\u30fc\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n\n\n\n<p>\u8996\u899a\u5316\u3057\u305f\u3044\u8cc3\u8cb8\u501f\u5951\u7d04\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>2021\u5e742\u67083\u65e5\uff1a\u5951\u7d04\u958b\u59cb<\/li>\n\n\n\n<li>2023\u5e742\u67082\u65e5\uff1a\u5951\u7d04\u7d42\u4e86<\/li>\n\n\n\n<li>2022\u5e748\u67083\u65e5\uff5e2022\u5e7412\u67082\u65e5\uff1a\u5bb6\u4e3b\/\u501f\u4e3b\u304c\u66f4\u65b0\u62d2\u5426\u306e\u901a\u77e5\u3092\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u671f\u9593<\/li>\n\n\n\n<li>2023\u5e745\u67081\u65e5\uff1a\u9ed9\u793a\u7684\u66f4\u65b0\u5f8c\u3001\u30c6\u30ca\u30f3\u30c8\u4e8b\u7531\u306b\u3088\u308b\u5951\u7d04\u89e3\u9664\u306e\u901a\u77e5<\/li>\n\n\n\n<li>2023\u5e748\u67081\u65e5: \u5951\u7d04\u7d42\u4e86\u3068\u4fdd\u8a3c\u91d1\u6255\u3044\u623b\u3057<\/li>\n<\/ul>\n\n\n\n<p>2021\u5e742\u67083\u65e5\u306b2\u5e74\u9593\u306e\u5168\u4e16\u754c\u5951\u7d04\u3092\u3059\u308b\u5834\u5408\u3001\u5bb6\u4e3b\u306b\u6cd5\u7684\u306b\u8a8d\u3081\u3089\u308c\u308b\u4e8b\u7531\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u5951\u7d04\u7d42\u4e86\u65e5(2023\u5e742\u67082\u65e5)\u4ee5\u524d\u306b <strong>6\u30f6\u6708\u9593<\/strong>\u3067\u3042\u308b2022\u5e748\u67083\u65e5\u304b\u3089\u5951\u7d04\u7d42\u4e86\u65e5\u524d\u307e\u3067 <strong>2\u30f6\u6708<\/strong>\u3067\u3042\u308b2022\u5e7412\u67082\u65e5\u307e\u3067\u306b\u66f4\u65b0\u62d2\u5426\u306e\u901a\u77e5\u3092\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u5bb6\u4e3b\u3068\u501f\u4e3b\u306f\u3001\u500b\u4eba\u7684\u306a\u4e8b\u60c5\u3067\u5f15\u3063\u8d8a\u3057\u3092\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u5834\u5408\u3001\u5951\u7d04\u7d42\u4e86\u65e5\u4ee5\u524d\u306b\u306f <strong>2\u30f6\u6708<\/strong>\u3067\u3042\u308b2022\u5e7412\u67082\u65e5\u307e\u3067\u306b\u66f4\u65b0\u62d2\u5426\u306e\u901a\u77e5\u3092\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u72b6\u6cc1\u3067\u3001\u9ed9\u793a\u7684\u306a\u66f4\u65b0\u3067\u5168\u4e16\u754c\u5951\u7d04\u304c2\u5e74\u5ef6\u9577\u3055\u308c\u305f\u3068\u4eee\u5b9a\u3059\u308b\u3068\u30012023\u5e745\u67081\u65e5\u306b\u30c6\u30ca\u30f3\u30c8\u306e\u90fd\u5408\u3067\u5951\u7d04\u89e3\u9664\u306e\u901a\u77e5\u30922023\u5e745\u67081\u65e5\u306b\u884c\u3063\u305f\u5834\u5408\u3001\u5bb6\u4e3b\u306f\u901a\u77e5\u3092\u53d7\u3051\u305f\u65e5\u304b\u30893\u30f6\u6708\u5f8c\u306e2023\u5e748\u67081\u65e5\u306b\u6577\u91d1\u3092\u6255\u308f\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u3067\u306f\u3001\u3053\u306e\u8907\u96d1\u306a\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306b\u3064\u3044\u3066\u3001R\u3092\u4f7f\u3063\u3066\u8996\u899a\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30ac\u30f3\u30c8\u30c1\u30e3\u30fc\u30c8\u30a8\u30af\u30bb\u30eb\u306a\u3057\u3067\u4f5c\u308bR\u30b3\u30fc\u30c9\u306e\u8aac\u660e<\/h2>\n\n\n\n<p>\u307e\u305a\u3001\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (!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\">\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u751f\u6210<\/h3>\n\n\n\n<p>\u53ef\u8996\u5316\u3059\u308b\u30c7\u30fc\u30bf\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002 \u5404\u671f\u9593\u3068\u958b\u59cb\u65e5\u3068\u7d42\u4e86\u65e5\u3092\u542b\u3080\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df &lt;- data.frame(\n  Task = c(&quot;\u521d\u671f\u5951\u7d04\u671f\u9593&quot;, &quot;\u5bb6\u4e3b\u901a\u77e5\u53ef\u80fd\u671f\u9593&quot;, &quot;\u30c6\u30ca\u30f3\u30c8\u901a\u77e5\u53ef\u80fd\u671f\u9593&quot;\u3001\n           &quot;\u66f4\u65b0\u5951\u7d04\u671f\u9593&quot;, &quot;\u901a\u77e5\u5f8c3\u30f6\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;))\u3001\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;)))\u3001\n  Section = c(&quot;\u521d\u671f\u5951\u7d04&quot;, &quot;\u66f4\u65b0\u62d2\u5426\u901a\u77e5&quot;, &quot;\u66f4\u65b0\u62d2\u5426\u901a\u77e5&quot;\u3001\n              &quot;\u66f4\u65b0\u5951\u7d04&quot;, &quot;\u5951\u7d04\u89e3\u9664&quot;)\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u91cd\u8981\u306a\u65e5\u4ed8\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u91cd\u8981\u306a\u65e5\u4ed8\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u4f5c\u6210\u3057\u307e\u3059\u3002\u4e0a\u8a18\u3067\u4f5c\u6210\u3057\u305f\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306f\u67a0\u7d44\u307f\u3092\u4f5c\u308b\u305f\u3081\u306e\u30c7\u30fc\u30bf\u3067\u3042\u308a\u3001\u3053\u3053\u306b\u51fa\u3066\u304f\u308b\u65e5\u4ed8\u306f\u30c1\u30e3\u30fc\u30c8\u306b\u70b9\u7dda\u3068\u65e5\u4ed8\u30e9\u30d9\u30eb\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u3082\u306e\u3067\u3059\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;\u3001\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\">\u65e5\u4ed8\u30e9\u30d9\u30eb\u4f4d\u7f6e\u8abf\u6574\u6a5f\u80fd\u306e\u6539\u5584<\/h3>\n\n\n\n<p>\u65e5\u4ed8\u30e9\u30d9\u30eb\u304c\u91cd\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u4f4d\u7f6e\u3092\u8abf\u6574\u3059\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3053\u306e\u90e8\u5206\u304c\u96e3\u3057\u3044\u90e8\u5206\u3067\u3059\u304c\u3001\u8868\u793a\u3057\u305f\u3044\u65e5\u4ed8\u30e9\u30d9\u30eb\u304c\u8fd1\u3059\u304e\u308b\u3068\u91cd\u306a\u308a\u3059\u304e\u3066\u8b58\u5225\u304c\u96e3\u3057\u3044\u306e\u3067\u30017\u65e5\u4ee5\u5185\u306b\u8fd1\u3044\u65e5\u4ed8\u3092\u78ba\u8a8d\u3057\u3066\u4e0a\u4e0b\u306b\u5206\u96e2\u3059\u308b\u6a5f\u80fd\u3092\u5b9f\u88c5\u3057\u307e\u3059\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) { # 7\u65e5\u4ee5\u5185\u306b\u8fd1\u3044\u65e5\u4ed8\u3092\u78ba\u8a8d\u3059\u308b\n      positions[i] &lt;- (last_position + 1) %% % 2 # \u4ee5\u524d\u306e\u4f4d\u7f6e\u306b\u3088\u3063\u3066\u4e0a\u4e0b\u4ea4\u4e92\u306b\u79fb\u52d5\u3059\u308b\n      last_position &lt;- positions[i\uff3d\n    } else { } else\n      last_position &lt;- 0\n    }\n  } }\n  return(positions)\n} }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u65e5\u4ed8\u30e9\u30d9\u30eb\u4f4d\u7f6e\u8abf\u6574<\/h3>\n\n\n\n<p>\u4e0a\u8a18\u3067\u5b9a\u7fa9\u3057\u305f\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u65e5\u4ed8\u30e9\u30d9\u30eb\u306e\u4f4d\u7f6e\u3092\u8abf\u6574\u3057\u307e\u3059\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\">\u65e5\u4ed8\u30e9\u30d9\u30eb\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u751f\u6210<\/h3>\n\n\n\n<p>\u30e9\u30d9\u30eb\u4f4d\u7f6e\u3092\u542b\u3080\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3059\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  position = label_positions\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d7\u30ed\u30c3\u30c8(\u30c1\u30e3\u30fc\u30c8)\u4f5c\u6210\u30fb\u51fa\u529b<\/h3>\n\n\n\n<p>ggplot2\u3092\u4f7f\u7528\u3057\u3066\u30d7\u30ed\u30c3\u30c8\u3092\u751f\u6210\u3057\u307e\u3059\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;%Y\u5e74%m\u6708&quot;, date_breaks = &quot;3\u30f6\u6708&quot;) + scale_x_date(date_labels = &quot;%Y\u5e74%m\u6708&quot;)\n  scale_y_discrete(limits = c(df$Task, &quot;&quot;, &quot;&quot;)) + scale_y_discrete()\n  theme_minimal() + + theme_minimal()\n  labs(title = &quot;\u8cc3\u8cb8\u501f\u5951\u7d04\u66f4\u65b0\u30fb\u89e3\u7d04\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb(\u4f8b)&quot;\u3001\n       x = &quot;\u65e5\u4ed8&quot;, y = &quot;&quot;) + labs(title = &quot;\u66f4\u65b0\u65e5&quot;, x = &quot;\u66f4\u65b0\u65e5&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\nprint(p)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">PNG\u5f62\u5f0f\u3067\u4fdd\u5b58<\/h3>\n\n\n\n<p>\u7d50\u679c\u306e\u30d7\u30ed\u30c3\u30c8\u3092PNG\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\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\u5168\u306a\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u4e0a\u3067\u8aac\u660e\u3057\u305f\u5168\u4f53\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u3059\u3002\u30b3\u30d4\u30da\u3057\u3066\u5b9f\u884c\u3059\u308b\u3068\u3001\u30dd\u30b9\u30c8\u4e0a\u90e8\u306b\u8868\u793a\u3055\u308c\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\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\">\u6574\u7406\u3059\u308b<\/h2>\n\n\n\n<p>\u4eca\u56de\u306f\u3001R\u3092\u4f7f\u3063\u3066\u8cc3\u8cb8\u501f\u5951\u7d04\u306e\u66f4\u65b0\u3068\u89e3\u7d04\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3092\u8996\u899a\u5316\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002 \u8907\u96d1\u306a\u5951\u7d04\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3092\u8996\u899a\u5316\u3055\u308c\u305f\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u8868\u3067\u8868\u73fe\u3059\u308b\u3068\u3001\u91cd\u8981\u306a\u65e5\u4ed8\u3092\u4e00\u76ee\u3067\u7c21\u5358\u306b\u628a\u63e1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u3001\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u30c7\u30fc\u30bf\u3092\u6e96\u5099\u3057\u305f\u5f8c\u3001\u65e5\u4ed8\u30e9\u30d9\u30eb\u304c\u91cd\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u8abf\u6574\u3059\u308b\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002 \u305d\u306e\u5f8c\u3001ggplot2\u3092\u4f7f\u7528\u3057\u3066\u8cc3\u8cb8\u501f\u5951\u7d04\u671f\u9593\u3068\u91cd\u8981\u306a\u65e5\u4ed8\u3092\u542b\u3080\u53ef\u8996\u5316\u3092\u751f\u6210\u3057\u3001\u3053\u308c\u3092PNG\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58\u3059\u308b\u30d7\u30ed\u30bb\u30b9\u3092\u8aac\u660e\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30bc\u30fc\u30b7\u30e7\u30f3\u624b\u6cd5\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u8cc3\u8cb8\u501f\u5951\u7d04\u3060\u3051\u3067\u306a\u304f\u3001\u69d8\u3005\u306a\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u7ba1\u7406\u3084\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u8a08\u753b\u306b\u3082\u5f79\u7acb\u3061\u307e\u3059\u3002\u4eca\u5f8c\u3082\u69d8\u3005\u306a\u30c7\u30fc\u30bf\u53ef\u8996\u5316\u6280\u6cd5\u3092\u63a2\u6c42\u3057\u3066\u3001\u30c7\u30fc\u30bf\u306e\u610f\u5473\u3092\u660e\u78ba\u306b\u4f1d\u3048\u308b\u65b9\u6cd5\u3092\u7df4\u7fd2\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3055\u3089\u306b\u3001\u8996\u899a\u5316\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u901a\u3058\u3066\u3001\u3088\u308a\u826f\u3044\u610f\u601d\u6c7a\u5b9a\u3092\u884c\u3046\u80fd\u529b\u3092\u9ad8\u3081\u3066\u3044\u304f\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u4f4f\u5b85\u8cc3\u8cb8\u501f\u4fdd\u8b77\u6cd5\u3067\u5b9a\u3081\u3089\u308c\u3066\u3044\u308b\u5951\u7d04\u66f4\u65b0\u3068\u89e3\u7d04\u306b\u95a2\u3059\u308b\u65e5\u4ed8\u3092\u30c6\u30ad\u30b9\u30c8\u3060\u3051\u3067\u628a\u63e1\u3059\u308b\u306e\u306f...<\/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\/ja\/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\/ja\/wp-json\/wp\/v2\/posts\/2315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/comments?post=2315"}],"version-history":[{"count":9,"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/posts\/2315\/revisions"}],"predecessor-version":[{"id":2333,"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/posts\/2315\/revisions\/2333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/media\/2320"}],"wp:attachment":[{"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/media?parent=2315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/categories?post=2315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/secondlife.lol\/ja\/wp-json\/wp\/v2\/tags?post=2315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}