forked from fjan05/packages-report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_wrangle-packages.R
39 lines (33 loc) · 1.19 KB
/
02_wrangle-packages.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(here)
library(tidyverse)
## create a data frame from data/installed-packages.csv
## with, e.g., readr::read_csv() or read.csv()
pkg <- read.csv(here("data", "installed-packages.csv"),
header = TRUE,
row.names = NULL)
## filter out packages in the default library
## keep variables Package and Built
## if you use dplyr, code like this will work:
apt <- pkg %>%
filter(LibPath == .libPaths()[1]) %>%
select(Package, Built)
## write this new, smaller data frame to data/add-on-packages.csv
write.csv(apt,
file = here("data", "add-on-packages.csv"),
quote = FALSE,
row.names = FALSE)
## make a frequency table of package by the version in Built
## if you use dplyr, code like this will work:
apt_freqtable <- apt %>%
count(Built) %>%
mutate(prop = n / sum(n))
## write this data frame to data/add-on-packages-freqtable.csv
## YES overwrite the files that are there now
## they came from me (Jenny)
## they are just examples
write.csv(apt_freqtable,
file = here("data", "add-on-packages-freqtable.csv"),
quote = FALSE,
row.names = FALSE)
## when this script works, stage & commit it and the csv files
## PUSH!