diff --git a/_freeze/posts/2023-10-08_datetimes-openxlsx/index/execute-results/html.json b/_freeze/posts/2023-10-08_datetimes-openxlsx/index/execute-results/html.json index 6d91cb8..0292b4e 100644 --- a/_freeze/posts/2023-10-08_datetimes-openxlsx/index/execute-results/html.json +++ b/_freeze/posts/2023-10-08_datetimes-openxlsx/index/execute-results/html.json @@ -1,7 +1,7 @@ { - "hash": "0336b99906c453f098aa7254d0eb64d1", + "hash": "3b90c1e963a837fd4b4d2e40145ec0b9", "result": { - "markdown": "---\ntitle: \"Detect date and time variables with openxlsx\"\nauthor: \"Layal C. Lettry\"\ndate: \"2023-10-08\"\ncategories: [openxlsx, date, datetime]\nimage: \"image.jpg\"\n---\n\n\n# Detect date variables\n\nWhen you try to read an excel file, the dates don't always look the way you would expect. You may see a vector of integers (or doubles) rather than a vector of dates. If you are using [openxlsx](https://github.com/ycphs/openxlsx), you can set `detectDates = TRUE` in the function `read.xlsx()`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(openxlsx)\nlibrary(tidyverse)\nlibrary(readxl)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nxlsxfile_path <- system.file(\"extdata\", \"readTest.xlsx\", package = \"openxlsx\")\n\n# Vector of doubles instead of dates\nxlsxfile_with_problems <- read.xlsx(xlsxfile_path, sheet = 3) |> \n as_tibble()\nxlsxfile_with_problems\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 2,083 × 5\n Date value word bool wordZ2 \n \n 1 41757 0.839 N-U-B-R-A FALSE FALSE-Z\n 2 41756 0.886 N-Z-P-S-Y TRUE TRUE-Z \n 3 41755 0.574 C-G-D-X-H TRUE TRUE-Z \n 4 41754 0.137 FALSE FALSE-Z\n 5 41753 0.369 B-K-A-O-W TRUE TRUE-Z \n 6 41752 NA H-P-G-O-K TRUE TRUE-Z \n 7 41751 0.842 F-P-C-L-T TRUE TRUE-Z \n 8 41750 0.227 A-N-Q-P-V TRUE TRUE-Z \n 9 41749 0.276 Y-E-B-K-O TRUE TRUE-Z \n10 41748 0.419 V-S-N-T-R TRUE TRUE-Z \n# ℹ 2,073 more rows\n```\n:::\n\n```{.r .cell-code}\nglimpse(xlsxfile_with_problems)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRows: 2,083\nColumns: 5\n$ Date 41757, 41756, 41755, 41754, 41753, 41752, 41751, 41750, 41749, …\n$ value 0.839076400, 0.886380000, 0.574131400, 0.136606500, 0.369258200…\n$ word \"N-U-B-R-A\", \"N-Z-P-S-Y\", \"C-G-D-X-H\", NA, \"B-K-A-O-W\", \"H-P-G-…\n$ bool FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…\n$ wordZ2 \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"…\n```\n:::\n\n```{.r .cell-code}\n# Vector of dates\nxlsxfile <- read.xlsx(xlsxfile_path, sheet = 3, detectDates = TRUE) |> \n as_tibble()\nxlsxfile\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 2,083 × 5\n Date value word bool wordZ2 \n \n 1 2014-04-28 0.839 N-U-B-R-A FALSE FALSE-Z\n 2 2014-04-27 0.886 N-Z-P-S-Y TRUE TRUE-Z \n 3 2014-04-26 0.574 C-G-D-X-H TRUE TRUE-Z \n 4 2014-04-25 0.137 FALSE FALSE-Z\n 5 2014-04-24 0.369 B-K-A-O-W TRUE TRUE-Z \n 6 2014-04-23 NA H-P-G-O-K TRUE TRUE-Z \n 7 2014-04-22 0.842 F-P-C-L-T TRUE TRUE-Z \n 8 2014-04-21 0.227 A-N-Q-P-V TRUE TRUE-Z \n 9 2014-04-20 0.276 Y-E-B-K-O TRUE TRUE-Z \n10 2014-04-19 0.419 V-S-N-T-R TRUE TRUE-Z \n# ℹ 2,073 more rows\n```\n:::\n\n```{.r .cell-code}\nglimpse(xlsxfile)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRows: 2,083\nColumns: 5\n$ Date 2014-04-28, 2014-04-27, 2014-04-26, 2014-04-25, 2014-04-24, 20…\n$ value 0.839076400, 0.886380000, 0.574131400, 0.136606500, 0.369258200…\n$ word \"N-U-B-R-A\", \"N-Z-P-S-Y\", \"C-G-D-X-H\", NA, \"B-K-A-O-W\", \"H-P-G-…\n$ bool FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…\n$ wordZ2 \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"…\n```\n:::\n:::\n\n\n# Convert double variables to date and time variables\n\nAnother way to convert a vector of integers is to use the function `convertToDate()` or `convertToDateTime()`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nother_file <- readxl_example(path = \"type-me.xlsx\")\nxlsxfile_datetime <- read.xlsx(other_file, sheet = 3) |> \n as_tibble() |> \n slice(2:3) |> \n select(`maybe.a.datetime?`) |> \n pull()\nxlsxfile_datetime\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] \"41051\" \"41026.479166666664\"\n```\n:::\n\n```{.r .cell-code}\nconvertToDate(xlsxfile_datetime[1])\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] \"2012-05-22\"\n```\n:::\n\n```{.r .cell-code}\nconvertToDateTime(xlsxfile_datetime[2])\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] \"2012-04-27 11:30:00 CEST\"\n```\n:::\n:::\n\n\n\n# Links\nThese examples are inspired by:\n\n- [https://rdrr.io/cran/openxlsxhttps://rdrr.io/cran/openxlsx](https://rdrr.io/cran/openxlsx/man/read.xlsx.html)\n\n- [https://readxl.tidyverse.org](https://readxl.tidyverse.org)\n", + "markdown": "---\ntitle: \"Detect date and time variables with {openxlsx}\"\nauthor: \"Layal C. Lettry\"\ndate: \"2023-10-08\"\ncategories: [openxlsx, date, datetime]\nimage: \"image.jpg\"\n---\n\n\n# Detect date variables\n\nWhen you try to read an excel file, the dates don't always look the way you would expect. You may see a vector of integers (or doubles) rather than a vector of dates. If you are using [\\{openxlsx\\}](https://github.com/ycphs/openxlsx), you can set `detectDates = TRUE` in the function `read.xlsx()`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(openxlsx)\nlibrary(tidyverse)\nlibrary(readxl)\n```\n:::\n\n::: {.cell}\n\n```{.r .cell-code}\nxlsxfile_path <- system.file(\"extdata\", \"readTest.xlsx\", package = \"openxlsx\")\n\n# Vector of doubles instead of dates\nxlsxfile_with_problems <- read.xlsx(xlsxfile_path, sheet = 3) |> \n as_tibble()\nxlsxfile_with_problems\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 2,083 × 5\n Date value word bool wordZ2 \n \n 1 41757 0.839 N-U-B-R-A FALSE FALSE-Z\n 2 41756 0.886 N-Z-P-S-Y TRUE TRUE-Z \n 3 41755 0.574 C-G-D-X-H TRUE TRUE-Z \n 4 41754 0.137 FALSE FALSE-Z\n 5 41753 0.369 B-K-A-O-W TRUE TRUE-Z \n 6 41752 NA H-P-G-O-K TRUE TRUE-Z \n 7 41751 0.842 F-P-C-L-T TRUE TRUE-Z \n 8 41750 0.227 A-N-Q-P-V TRUE TRUE-Z \n 9 41749 0.276 Y-E-B-K-O TRUE TRUE-Z \n10 41748 0.419 V-S-N-T-R TRUE TRUE-Z \n# ℹ 2,073 more rows\n```\n:::\n\n```{.r .cell-code}\nglimpse(xlsxfile_with_problems)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRows: 2,083\nColumns: 5\n$ Date 41757, 41756, 41755, 41754, 41753, 41752, 41751, 41750, 41749, …\n$ value 0.839076400, 0.886380000, 0.574131400, 0.136606500, 0.369258200…\n$ word \"N-U-B-R-A\", \"N-Z-P-S-Y\", \"C-G-D-X-H\", NA, \"B-K-A-O-W\", \"H-P-G-…\n$ bool FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…\n$ wordZ2 \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"…\n```\n:::\n\n```{.r .cell-code}\n# Vector of dates\nxlsxfile <- read.xlsx(xlsxfile_path, sheet = 3, detectDates = TRUE) |> \n as_tibble()\nxlsxfile\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 2,083 × 5\n Date value word bool wordZ2 \n \n 1 2014-04-28 0.839 N-U-B-R-A FALSE FALSE-Z\n 2 2014-04-27 0.886 N-Z-P-S-Y TRUE TRUE-Z \n 3 2014-04-26 0.574 C-G-D-X-H TRUE TRUE-Z \n 4 2014-04-25 0.137 FALSE FALSE-Z\n 5 2014-04-24 0.369 B-K-A-O-W TRUE TRUE-Z \n 6 2014-04-23 NA H-P-G-O-K TRUE TRUE-Z \n 7 2014-04-22 0.842 F-P-C-L-T TRUE TRUE-Z \n 8 2014-04-21 0.227 A-N-Q-P-V TRUE TRUE-Z \n 9 2014-04-20 0.276 Y-E-B-K-O TRUE TRUE-Z \n10 2014-04-19 0.419 V-S-N-T-R TRUE TRUE-Z \n# ℹ 2,073 more rows\n```\n:::\n\n```{.r .cell-code}\nglimpse(xlsxfile)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRows: 2,083\nColumns: 5\n$ Date 2014-04-28, 2014-04-27, 2014-04-26, 2014-04-25, 2014-04-24, 20…\n$ value 0.839076400, 0.886380000, 0.574131400, 0.136606500, 0.369258200…\n$ word \"N-U-B-R-A\", \"N-Z-P-S-Y\", \"C-G-D-X-H\", NA, \"B-K-A-O-W\", \"H-P-G-…\n$ bool FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…\n$ wordZ2 \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"FALSE-Z\", \"TRUE-Z\", \"TRUE-Z\", \"…\n```\n:::\n:::\n\n\n# Convert double variables to date and time variables\n\nAnother way to convert a vector of integers is to use the function `convertToDate()` or `convertToDateTime()`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nother_file <- readxl_example(path = \"type-me.xlsx\")\nxlsxfile_datetime <- read.xlsx(other_file, sheet = 3) |> \n as_tibble() |> \n slice(2:3) |> \n select(`maybe.a.datetime?`) |> \n pull()\nxlsxfile_datetime\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] \"41051\" \"41026.479166666664\"\n```\n:::\n\n```{.r .cell-code}\nconvertToDate(xlsxfile_datetime[1])\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] \"2012-05-22\"\n```\n:::\n\n```{.r .cell-code}\nconvertToDateTime(xlsxfile_datetime[2])\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] \"2012-04-27 11:30:00 CEST\"\n```\n:::\n:::\n\n\n# Sources\n\nThese examples are inspired by:\n\n- [https://rdrr.io/cran/openxlsxhttps://rdrr.io/cran/openxlsx](https://rdrr.io/cran/openxlsx/man/read.xlsx.html)\n\n- \n", "supporting": [], "filters": [ "rmarkdown/pagebreak.lua" diff --git a/_freeze/posts/2023-10-08_rename-columns-lookup/index/execute-results/html.json b/_freeze/posts/2023-10-08_rename-columns-lookup/index/execute-results/html.json index 66471ab..7d944b1 100644 --- a/_freeze/posts/2023-10-08_rename-columns-lookup/index/execute-results/html.json +++ b/_freeze/posts/2023-10-08_rename-columns-lookup/index/execute-results/html.json @@ -1,7 +1,7 @@ { - "hash": "e011a619a786acecc6faf99647157127", + "hash": "b5564be6455f6d7b8cc5cb0cf1491da0", "result": { - "markdown": "---\ntitle: \"Rename variables in a data frame using an external lookup table\"\nauthor: \"Layal C. Lettry\"\ndate: \"2023-10-08\"\ncategories: [unquote-splice, tidy evaluation, rename, any_of]\nimage: \"image.jpg\"\n---\n\n\n# Rename variables in a data frame using an external lookup table\n\nSuppose that a data frame is present with certain columns that possess the appropriate names, however, the remaining columns require renaming. An existing lookup table is ready to be used for setting new names to these specific columns.\n\nI found the solution by using tidy evaluation tools, namely the unquote-splice `!!!`, and by reading the [article written by Tim Tiefenbach](https://tim-tiefenbach.de/post/2022-rename-columns/#dplyr-tidyverse).\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(tidyverse)\n```\n:::\n\n\nHere is the data frame with 3 variables, namely `var1`, `var2` and `var4`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib <- tribble(\n ~var1, ~var2, ~var4,\n \"x\", \"a\", 1L,\n \"y\", \"b\", 2L,\n \"z\", \"c\", 3L\n)\ntest_tib\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 3 × 3\n var1 var2 var4\n \n1 x a 1\n2 y b 2\n3 z c 3\n```\n:::\n:::\n\n\nDefine the lookup table with the new names. Transform this lookup table into a named vector using `deframe()`. Do not forget that the first argument of `deframe()` should be the new names of the variable and the second one should have the actual names.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nnew_names <- tribble(\n ~names_var, ~new_names_var,\n \"var1\", \"Variable 1\",\n \"var2\", \"Variable 2\",\n \"var3\", \"Variable 3\",\n \"var4\", \"Variable 4\"\n)\nnew_names\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 4 × 2\n names_var new_names_var\n \n1 var1 Variable 1 \n2 var2 Variable 2 \n3 var3 Variable 3 \n4 var4 Variable 4 \n```\n:::\n\n```{.r .cell-code}\nnew_names_vec <- deframe(select(new_names, new_names_var, names_var))\nnew_names_vec\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nVariable 1 Variable 2 Variable 3 Variable 4 \n \"var1\" \"var2\" \"var3\" \"var4\" \n```\n:::\n:::\n\n\n# Solution using tidy evaluation and base R\n\nOur goal is to unpack the vector of column name pairs that are actually in our data frame. We could achieve this by using unquote-splice `!!!` which will splice the list of names into the dynamic dots `...` of `rename()`.\n\nHowever, the column `var3` is not found. An error appears.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib |>\n rename(!!!new_names_vec)\n```\n\n::: {.cell-output .cell-output-error}\n```\nError in `rename()`:\n! Can't rename columns that don't exist.\n✖ Column `var3` doesn't exist.\n```\n:::\n:::\n\n\nSelect only the variables which are in the named vector `new_names_vec`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib |>\n rename(!!!new_names_vec[new_names_vec %in% names(test_tib)])\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 3 × 3\n `Variable 1` `Variable 2` `Variable 4`\n \n1 x a 1\n2 y b 2\n3 z c 3\n```\n:::\n:::\n\n\n# Solution using dplyr\n\nInstead of selecting the common variables, you can use `any_of()` which does this selection automatically.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib |>\n rename(any_of(new_names_vec))\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 3 × 3\n `Variable 1` `Variable 2` `Variable 4`\n \n1 x a 1\n2 y b 2\n3 z c 3\n```\n:::\n:::\n\n\n# Sources\n\nThese examples are inspired by:\n\n- [Article written by Tim Tiefenbach](https://tim-tiefenbach.de/post/2022-rename-columns/#dplyr-tidyverse)\n\n- \n\n- \n\n- [https://rlang.r-lib.org/reference/topic-inject.html#splicing-with--1](https://rlang.r-lib.org/reference/topic-inject.html#splicing-with--1)\n\n- \n", + "markdown": "---\ntitle: \"Rename variables in a data frame using an external lookup table\"\nauthor: \"Layal C. Lettry\"\ndate: \"2023-10-08\"\ncategories: [unquote-splice, tidy evaluation, rename, any_of]\nimage: \"image.jpg\"\n---\n\n\n# Rename variables in a data frame using an external lookup table\n\nSuppose that a data frame is present with certain columns that possess the appropriate names, however, the remaining columns require renaming. An existing lookup table is ready to be used for setting new names to these specific columns.\n\nI found the solution by using tidy evaluation tools, namely the unquote-splice `!!!`, and by reading the [article written by Tim Tiefenbach](https://tim-tiefenbach.de/post/2022-rename-columns/#dplyr-tidyverse).\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(tidyverse)\n```\n:::\n\n\nHere is the data frame with 3 variables, namely `var1`, `var2` and `var4`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib <- tribble(\n ~var1, ~var2, ~var4,\n \"x\", \"a\", 1L,\n \"y\", \"b\", 2L,\n \"z\", \"c\", 3L\n)\ntest_tib\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 3 × 3\n var1 var2 var4\n \n1 x a 1\n2 y b 2\n3 z c 3\n```\n:::\n:::\n\n\nDefine the lookup table with the new names. Transform this lookup table into a named vector using `deframe()`. Do not forget that the first argument of `deframe()` should be the new names of the variable and the second one should have the actual names.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nnew_names <- tribble(\n ~names_var, ~new_names_var,\n \"var1\", \"Variable 1\",\n \"var2\", \"Variable 2\",\n \"var3\", \"Variable 3\",\n \"var4\", \"Variable 4\"\n)\nnew_names\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 4 × 2\n names_var new_names_var\n \n1 var1 Variable 1 \n2 var2 Variable 2 \n3 var3 Variable 3 \n4 var4 Variable 4 \n```\n:::\n\n```{.r .cell-code}\nnew_names_vec <- deframe(select(new_names, new_names_var, names_var))\nnew_names_vec\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nVariable 1 Variable 2 Variable 3 Variable 4 \n \"var1\" \"var2\" \"var3\" \"var4\" \n```\n:::\n:::\n\n\n# Solution using tidy evaluation and base R\n\nOur goal is to unpack the vector of column name pairs that are actually in our data frame. We could achieve this by using unquote-splice `!!!` which will splice the list of names into the dynamic dots `...` of `rename()`.\n\nHowever, the column `var3` is not found. An error appears.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib |>\n rename(!!!new_names_vec)\n```\n\n::: {.cell-output .cell-output-error}\n```\nError in `rename()`:\n! Can't rename columns that don't exist.\n✖ Column `var3` doesn't exist.\n```\n:::\n:::\n\n\nSelect only the variables which are in the named vector `new_names_vec`.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib |>\n rename(!!!new_names_vec[new_names_vec %in% names(test_tib)])\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 3 × 3\n `Variable 1` `Variable 2` `Variable 4`\n \n1 x a 1\n2 y b 2\n3 z c 3\n```\n:::\n:::\n\n\n# Solution using \\{dplyr\\}\n\nInstead of selecting the common variables, you can use `any_of()` which does this selection automatically.\n\n\n::: {.cell}\n\n```{.r .cell-code}\ntest_tib |>\n rename(any_of(new_names_vec))\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 3 × 3\n `Variable 1` `Variable 2` `Variable 4`\n \n1 x a 1\n2 y b 2\n3 z c 3\n```\n:::\n:::\n\n\n# Sources\n\nThese examples are inspired by:\n\n- [Article written by Tim Tiefenbach](https://tim-tiefenbach.de/post/2022-rename-columns/#dplyr-tidyverse)\n\n- \n\n- \n\n- [https://rlang.r-lib.org/reference/topic-inject.html#splicing-with--1](https://rlang.r-lib.org/reference/topic-inject.html#splicing-with--1)\n\n- \n", "supporting": [], "filters": [ "rmarkdown/pagebreak.lua" diff --git a/posts/2023-10-08_datetimes-openxlsx/index.qmd b/posts/2023-10-08_datetimes-openxlsx/index.qmd index 5a67dfc..66b4ee0 100644 --- a/posts/2023-10-08_datetimes-openxlsx/index.qmd +++ b/posts/2023-10-08_datetimes-openxlsx/index.qmd @@ -1,5 +1,5 @@ --- -title: "Detect date and time variables with openxlsx" +title: "Detect date and time variables with {openxlsx}" author: "Layal C. Lettry" date: "2023-10-08" categories: [openxlsx, date, datetime] @@ -8,7 +8,7 @@ image: "image.jpg" # Detect date variables -When you try to read an excel file, the dates don't always look the way you would expect. You may see a vector of integers (or doubles) rather than a vector of dates. If you are using [openxlsx](https://github.com/ycphs/openxlsx), you can set `detectDates = TRUE` in the function `read.xlsx()`. +When you try to read an excel file, the dates don't always look the way you would expect. You may see a vector of integers (or doubles) rather than a vector of dates. If you are using [\{openxlsx\}](https://github.com/ycphs/openxlsx), you can set `detectDates = TRUE` in the function `read.xlsx()`. ```{r} #| label: load_libraries @@ -58,11 +58,10 @@ convertToDate(xlsxfile_datetime[1]) convertToDateTime(xlsxfile_datetime[2]) ``` - # Sources These examples are inspired by: -- [https://rdrr.io/cran/openxlsxhttps://rdrr.io/cran/openxlsx](https://rdrr.io/cran/openxlsx/man/read.xlsx.html) +- [https://rdrr.io/cran/openxlsxhttps://rdrr.io/cran/openxlsx](https://rdrr.io/cran/openxlsx/man/read.xlsx.html) -- [https://readxl.tidyverse.org](https://readxl.tidyverse.org) +- diff --git a/posts/2023-10-08_rename-columns-lookup/index.qmd b/posts/2023-10-08_rename-columns-lookup/index.qmd index 297f722..9722dcc 100644 --- a/posts/2023-10-08_rename-columns-lookup/index.qmd +++ b/posts/2023-10-08_rename-columns-lookup/index.qmd @@ -81,7 +81,7 @@ test_tib |> rename(!!!new_names_vec[new_names_vec %in% names(test_tib)]) ``` -# Solution using dplyr +# Solution using \{dplyr\} Instead of selecting the common variables, you can use `any_of()` which does this selection automatically.