Skip to content

Commit

Permalink
feat: add 2 posts about progress bars and now
Browse files Browse the repository at this point in the history
  • Loading branch information
Layalchristine24 committed Oct 12, 2023
1 parent ce8a972 commit 214c736
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 2 deletions.
14 changes: 14 additions & 0 deletions _freeze/posts/2023-10-12_now/index/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"hash": "6e511d463cb13866a65e5bbb842de0fe",
"result": {
"markdown": "---\ntitle: \"Extract only stable functions from a tidyverse package\"\nauthor: \"Layal C. Lettry\"\ndate: \"2023-10-12\"\ncategories: [tidyverse, deprecated, superseded, defunct, questioning, reexported]\nimage: \"image.jpg\"\n---\n\n\n# Package {now}\n\nThanks to [Antoine Fabri](https://x.com/antoine_fabri?s=20)'s [post](https://x.com/antoine_fabri/status/1712063122989547718?s=20), I discovered the package [now](https://github.com/moodymudskipper/now) which allows to remove deprecated, superseded, defunct, questioning or reexported functions from tidyverse packages.\n\nThe [README.md](https://github.com/moodymudskipper/now#readme) file is explains \nhow we can see how many functions remain after having removed all the\ndeprecated, superseded, defunct, questioning or reexported ones. See this table \nwhich comes from the [README.md](https://github.com/moodymudskipper/now#readme) .\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# removing additionally all experimental and questioning features, along with reexports\nlibrary(tidyverse)\n\nbefore <- sapply(tidyverse_packages(), \\(pkg) length(getNamespaceExports(pkg)))\n\nnow::clean_up_tidyverse(c(\"experimental\", \"superseded\", \"deprecated\", \"defunct\", \"questioning\", \"reexports\"))\n\nafter <- sapply(tidyverse_packages(), \\(pkg) length(getNamespaceExports(pkg)))\n\nleft_join(enframe(before, value = \"before\"), enframe(after, value = \"after\"), \n by = \"name\") |> \n filter(after != before) |>\n mutate(keep_ratio = sprintf(\"%2.0f%%\", 100 * after / before)) |>\n arrange(keep_ratio) |>\n knitr::kable()\n```\n\n::: {.cell-output-display}\n|name | before| after|keep_ratio |\n|:-------------|------:|-----:|:----------|\n|tidyr | 70| 30|43% |\n|purrr | 189| 91|48% |\n|tibble | 46| 22|48% |\n|dplyr | 293| 148|51% |\n|rvest | 40| 23|58% |\n|ragg | 10| 6|60% |\n|pillar | 45| 28|62% |\n|broom | 9| 6|67% |\n|readxl | 13| 9|69% |\n|rlang | 440| 340|77% |\n|jsonlite | 28| 23|82% |\n|hms | 12| 10|83% |\n|googledrive | 87| 76|87% |\n|googlesheets4 | 53| 47|89% |\n|haven | 28| 26|93% |\n|readr | 115| 107|93% |\n|dbplyr | 162| 153|94% |\n|forcats | 39| 37|95% |\n|stringr | 59| 56|95% |\n|ggplot2 | 536| 512|96% |\n|lubridate | 205| 198|97% |\n|modelr | 34| 33|97% |\n:::\n:::\n\n\n I assign the copyright for the content of the code above to [Antoine Fabri](https://x.com/antoine_fabri?s=20).\n",
"supporting": [],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {},
"engineDependencies": {},
"preserve": {},
"postProcess": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"hash": "d042ee2a54fcf3f8fe3e005cc3f627bc",
"result": {
"markdown": "---\ntitle: \"Progress bars\"\nauthor: \"Layal C. Lettry\"\ndate: \"2023-10-12\"\ncategories: [openxlsx, date, datetime]\nimage: \"image.jpg\"\n---\n\n\n# Progress bars\n\nSometimes, you want to include a progress bar in your pipeline, to see how much\ncode has been executed and how much is left. \n\nHere are some possibilities to do that.\n\n## The \\{purrr\\} package\n\n\n::: {.cell}\n\n```{.r .cell-code}\npurrr::walk(1:3, Sys.sleep, .progress = TRUE)\n```\n:::\n\n\n## The \\{cli\\} package\n\nYou can also create a progress bar with the \\{cli\\} package. Please refer to [this article](https://cli.r-lib.org/articles/progress.html) presents several possibilities to create a progress bar. \n",
"supporting": [],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {},
"engineDependencies": {},
"preserve": {},
"postProcess": true
}
}
4 changes: 2 additions & 2 deletions about.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ about:
href: https://github.com/Layalchristine24/rdiscovery
---

In this blog, I intend to compose a post detailing each discovery that I have made through the regular utilization of R.
In this blog, I intend to compose a post detailing each discovery that I have made through the regular utilization of R.

I consider it to be mainly a daybook where I can easily find my solutions again. You may find some simple cases, but also more complex ones.
I consider it to be mainly a daybook where I can easily find my solutions and my findings again. You may find some simple cases, but also more complex ones. I will also report and demonstrate useful packages or repositories from other developers to whom I assign the copyright for the content of these particular posts.

Hopefully, you will also encounter something of value to yourself!

Expand Down
Binary file added posts/2023-10-12_now/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions posts/2023-10-12_now/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "Extract only stable functions from a tidyverse package"
author: "Layal C. Lettry"
date: "2023-10-12"
categories: [tidyverse, deprecated, superseded, defunct, questioning, reexported]
image: "image.jpg"
---

# Package {now}

Thanks to [Antoine Fabri](https://x.com/antoine_fabri?s=20)'s [post](https://x.com/antoine_fabri/status/1712063122989547718?s=20), I discovered the package [now](https://github.com/moodymudskipper/now) which allows to remove deprecated, superseded, defunct, questioning or reexported functions from tidyverse packages.

The [README.md](https://github.com/moodymudskipper/now#readme) file is explains
how we can see how many functions remain after having removed all the
deprecated, superseded, defunct, questioning or reexported ones. See this table
which comes from the [README.md](https://github.com/moodymudskipper/now#readme) .


```{r}
#| label: clean_package
#| message: false
#| warning: false
# removing additionally all experimental and questioning features, along with reexports
library(tidyverse)
before <- sapply(tidyverse_packages(), \(pkg) length(getNamespaceExports(pkg)))
now::clean_up_tidyverse(c("experimental", "superseded", "deprecated", "defunct", "questioning", "reexports"))
after <- sapply(tidyverse_packages(), \(pkg) length(getNamespaceExports(pkg)))
left_join(enframe(before, value = "before"), enframe(after, value = "after"),
by = "name") |>
filter(after != before) |>
mutate(keep_ratio = sprintf("%2.0f%%", 100 * after / before)) |>
arrange(keep_ratio) |>
knitr::kable()
```

I assign the copyright for the content of the code above to [Antoine Fabri](https://x.com/antoine_fabri?s=20).
Binary file added posts/2023-10-12_progress-bars/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions posts/2023-10-12_progress-bars/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "Progress bars"
author: "Layal C. Lettry"
date: "2023-10-12"
categories: [openxlsx, date, datetime]
image: "image.jpg"
---

# Progress bars

Sometimes, you want to include a progress bar in your pipeline, to see how much
code has been executed and how much is left.

Here are some possibilities to do that.

## The \{purrr\} package

```{r}
#| label: purrr_walk
#| message: false
#| warning: false
purrr::walk(1:3, Sys.sleep, .progress = TRUE)
```

## The \{cli\} package

You can also create a progress bar with the \{cli\} package. Please refer to [this article](https://cli.r-lib.org/articles/progress.html) presents several possibilities to create a progress bar.

0 comments on commit 214c736

Please sign in to comment.