Skip to content

Commit

Permalink
update make_data to handle python scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nrennie committed Apr 4, 2024
1 parent 3694724 commit 226eda7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions data/make-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ for (i in seq_len(nrow(all_weeks))) {

# get all packages used
tt_file <- list.files(file.path(tt_week$year, tt_week$week),
pattern = ".R", full.names = TRUE
pattern = ".R|.py", full.names = TRUE
)[1]
all_weeks[i, "code_fpath"] <- tt_file
tt_pkgs <- att_from_rscript(tt_file) |>
stringr::str_flatten_comma()
all_weeks[i, "pkgs"] <- tt_pkgs
if (stringr::str_detect(tt_file, ".R")) {
tt_pkgs <- att_from_rscript(tt_file) |>
stringr::str_flatten_comma()
all_weeks[i, "pkgs"] <- tt_pkgs
} else {
all_weeks[i, "pkgs"] <- "None"
}

}

# packages to binary variables
Expand All @@ -89,7 +94,8 @@ binary_pkgs <- all_weeks |>
complete(week, pkgs) |>
mutate(value = replace_na(value, 0)) |>
unique() |>
pivot_wider(names_from = pkgs, values_from = value)
pivot_wider(names_from = pkgs, values_from = value) |>
select(-None)

# join
all_weeks <- all_weeks |>
Expand Down

0 comments on commit 226eda7

Please sign in to comment.