Skip to content

Commit

Permalink
add convert_trawl_cols fn to post-process archive trawl data
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Nov 22, 2022
1 parent c4104b3 commit b3dbae8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repos:
args: [--style_pkg=spaceout, --style_fun=spaceout_style]
additional_dependencies:
- ropensci-review-tools/spaceout
- styler
#- id: roxygenize
#additional_dependencies:
#- pkgbuild
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkgstats
Title: Metrics of R Packages
Version: 0.1.1.067
Version: 0.1.1.068
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
49 changes: 49 additions & 0 deletions R/archive-trawl.R
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,52 @@ get_pkg_version <- function (path) {

c (pkg, v)
}

#' Internal function to convert columns in result of archive trawl to expected,
#' generally numeric, types.
#' @noRd
convert_trawl_columns <- function (x) {

int_cols <- c (
"^files\\_",
"^loc\\_",
"^blank\\_",
"^comment\\_",
"^indentation$",
"^rel\\_space$",
"^num\\_",
"^desc\\_n\\_",
"^n\\_fns\\_(r|s)",
"^n\\_edges",
"^n\\_clusters"
)
num_cols <- c (
"^rel\\_space\\_",
"^nexpr$",
"^rel\\_space\\_",
"^data\\_size\\_",
"^n\\_fns\\_per",
"^npars\\_",
"^doclines\\_per\\_",
"^docchars\\_per\\_",
"^centrality\\_",
"^node\\_degree\\_",
"^cpl\\_instability"
)

cols <- names (x)

int_cols <- lapply (int_cols, function (i) grep (i, cols))
int_cols <- sort (unlist (int_cols))
for (i in int_cols) {
storage.mode (x [[i]]) <- "integer"
}

num_cols <- lapply (num_cols, function (i) grep (i, cols))
num_cols <- sort (unlist (num_cols))
for (i in num_cols) {
storage.mode (x [[i]]) <- "numeric"
}

return (x)
}
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/pkgstats",
"issueTracker": "https://github.com/ropensci-review-tools/pkgstats/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.1.067",
"version": "0.1.1.068",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit b3dbae8

Please sign in to comment.