-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from ThinkR-open/att_from_data
Att from data
- Loading branch information
Showing
20 changed files
with
153 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: attachment | ||
Title: Deal with Dependencies | ||
Version: 0.4.2.9000 | ||
Version: 0.4.2.9001 | ||
Authors@R: c( | ||
person("Sébastien", "Rochette", , "[email protected]", role = c("cre", "aut"), | ||
comment = c(ORCID = "0000-0002-1565-9313")), | ||
|
@@ -24,9 +24,8 @@ License: GPL-3 | |
URL: https://thinkr-open.github.io/attachment/, | ||
https://github.com/ThinkR-open/attachment | ||
BugReports: https://github.com/ThinkR-open/attachment/issues | ||
VignetteBuilder: | ||
knitr | ||
Config/fusen/version: 0.5.0.9006 | ||
VignetteBuilder: knitr | ||
Config/fusen/version: 0.6.0 | ||
Config/Needs/website: ThinkR-open/thinkrtemplate | ||
Config/testthat/edition: 3 | ||
Encoding: UTF-8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#' Look for functions called in data loading code | ||
#' | ||
#' @param chr A character vector containing the code as a string. The code should follow the pattern used for loading data with `data()`, specifying the dataset and package. | ||
#' @return A character vector containing the names of the packages from which datasets are being loaded. | ||
#' @importFrom stringr str_extract_all | ||
#' @export | ||
#' @examples | ||
#' | ||
#' vec_char <- 'data("starwars", package = "dplyr")' | ||
#' att_from_data(vec_char) | ||
att_from_data <- function(chr) { | ||
pkg <- | ||
str_extract_all( | ||
chr, | ||
'(?<=data\\(\\".{1,100}\\"\\,\\s{0,5}package\\s{0,5}\\=\\s{0,5}\\\")[[:alnum:]\\.]+(?=\\\"\\))' | ||
) |> | ||
unlist() | ||
return(pkg) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
test_that("att_from_data works with a single package", { | ||
|
||
input1 <- 'data("starwars", package = "dplyr")' | ||
expect_equal(att_from_data(input1), "dplyr") | ||
|
||
}) | ||
|
||
test_that("att_from_data works with multi package", { | ||
|
||
input1 <- 'data("starwars", package = "dplyr")data("dataset", package = "pkgfake")' | ||
expect_equal(att_from_data(input1), c("dplyr", "pkgfake")) | ||
|
||
}) | ||
|
||
|
||
test_that("att_from_data works with extra spaces", { | ||
|
||
input1 <- 'data("starwars",package = "dplyr")' | ||
expect_equal(att_from_data(input1), "dplyr") | ||
|
||
}) |
Oops, something went wrong.