Nothing
test_that("clean_authors() works", {
author_list <-
c(
"Haddaway, N.R., A. Feirman, M.J. Grainger, C.T. Gray, E. Tanriver-Ayder, S. Dhaubanjar, & M.J Westgate",
"Grames, E.M., A.N. Stillman, M.W. Tingley AND C.S. Elphick"
)
author_list |>
clean_authors()
expect_false(any(grepl("&", clean_authors(author_list))))
expect_false(any(grepl("AND", clean_authors(author_list))))
})
test_that("clean_colnames() works", {
cleaned <- tibble::tibble(".title..." = 1,
"X..YEAR" = 2,
"authors.." = 3,
".AUTHOR" = 4) |>
clean_colnames() |>
colnames()
expect_false(any(grepl("[[:punct::]]", cleaned)))
expect_false(any(duplicated(cleaned)))
expect_false(any(grepl("^(X|Y|Z)\\.+", cleaned)))
})
test_that("clean_df() cleans authors, colnames and factors", {
test_df <- tibble::tibble(
authors = c("Haddaway, N.R., A. Feirman AND M.J. Grainger", "Some authors"),
"..misc." = c("text", "text2"),
JOURNAL = as.factor(c("A journal", "Another journal"))
)
result <- clean_df(test_df)
expect_equal(colnames(result),
c("author", "misc", "journal"))
expect_false(any(grepl("AND", result$author)))
test_cols <- colnames(result)
expect_false(any(grepl("[[:punct::]]", test_cols)))
expect_equal(tolower(test_cols), test_cols)
expect_false(any(unlist(lapply(result, is.factor))))
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.