Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conf 2023 solutions #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions R/01_write-installed-packages.R
Expand Up @@ -2,6 +2,9 @@

# 1. Create a data frame of your installed packages. ---------------------------
# hint: installed.packages() is the function you need
library(tidyverse)
df_pkgs <- installed.packages() |>
as_tibble()

# optional: select just some of the variables, such as
# * Package
Expand All @@ -13,6 +16,7 @@
# 2. Write this data frame to data/installed-packages.csv. ---------------------
# hint: readr::write_csv() or write.table()
# idea: try using here::here() to create the file path
readr::write_csv(df_pkgs, "data/installed-packages.csv")

# YES overwrite the file that is there now (or delete it first)
# that is an old result from Jenny
Expand Down
10 changes: 10 additions & 0 deletions R/02_wrangle-packages.R
Expand Up @@ -3,6 +3,8 @@
# 1. Create a data frame by reading from data/installed-packages.csv. ----------
# hint: readr::read_csv() or read.csv()
# idea: try using here::here() to create the file path
library(tidyverse)
df_pkgs <- readr::read_csv(here::here("data", "installed-packages.csv"))


# 2. Filter out the base and recommended packages. -----------------------------
Expand All @@ -16,6 +18,10 @@ df_pkgs_addon <- df_pkgs |>
# 3. Write this new, smaller data frame to data/add-on-packages.csv. -----------
# hint: readr::write_csv() or write.table()
# idea: try using here::here() to create the file path
readr::write_csv(
df_pkgs_addon,
here::here("data", "add-on-packages.csv")
)

# 4. Summarize the packages with a frequency table of the version in Built. ----
# if you use dplyr, code like this will work:
Expand All @@ -30,3 +36,7 @@ pkgs_addon_freqtable <- df_pkgs_addon |>
# YES overwrite the files that are there now
# they are old output from Jenny
# they are just examples
readr::write_csv(
pkgs_addon_freqtable,
here::here("data", "add-on-packages-freqtable.csv")
)
10 changes: 10 additions & 0 deletions R/03_barchart-packages-built.R
Expand Up @@ -3,6 +3,10 @@
# 1. Read data/add-on-packages-freqtable.csv into a data frame.-----------------
# hint: readr::read_csv() or read.csv()
# idea: try using here::here() to create the file path
library(tidyverse)
pkgs_addon_freqtable <- readr::read_csv(
here::here("data", "pkgs_addon_freqtable.csv")
)

# 2. Make a barchart from the frequency table you read in. ---------------------
# if you use ggplot2, code like this will work:
Expand All @@ -15,3 +19,9 @@ ggplot(pkgs_addon_freqtable, aes(x = Built, y = n)) +
# ----
# YES overwrite the file that is there now
# that is old output from Jenny
ggsave(
here::here(
"figs",
"built-barchart.png"
)
)
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -12,6 +12,6 @@ usethis::use_course("rstats-wtf/wtf-packages-report")
- `R/02_wrangle-packages.R`
- `R/03_barchart-packages-built.R`
* It's OK if you don't finish! We can keep working on this later.
* If you finish quickly, write an R script to run the whole analysis and, perhaps, another script that does a `make clean` style reset.
* If you finish quickly, write an R script to run the whole analysis.

Solutions are in the [solutions](https://github.com/rstats-wtf/wtf-packages-report/commit/f9fe5aacc004cf8c79356acdd4638f641f6f8ae7) branch.