Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure generate_author_yml retains affiliation order by person #570

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion R/generate_author_yml.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ generate_author_yml <- function(
)

authors <- sapply(seq_along(researchers), function(i) {
i_affil = paste(affil_numeric[affil_order %in% unlist(researchers[i])], collapse = ",")
i_affil <- affil_numeric[match(unlist(researchers[i]), names(affil_numeric))]
i_affil <- paste(i_affil, collapse = ",")

if (names(researchers)[i] == corres_name) {
extra <- as.character(
Expand Down
5 changes: 4 additions & 1 deletion inst/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

# Upcoming release

- For ANOVA methods, *MSE*s are again returned if requested by the user (reported by @Sashpta, [#562](https://github.com/crsh/papaja/issues/562)). The global default for reporting *MSE*s now depends on the [**effectsize**](https://CRAN.r-project.org/package=effectsize) package: If **effectsize** is installed, the default for reporting *MSE*s is `FALSE`, if **effectsize** is not installed, the default is `TRUE`.

### Existing functions

- `generate_author_yml()`
- Now preserves affiliation order for each author (see #569).

# papaja 0.1.2

Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test-generate_author_yml.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,27 @@ test_that("generate_author_yml enforces unique authors/affiliations", {
)

})

test_that("generate_author_yml preserves affiliation order", {

text <- generate_author_yml(
researchers = list(
"James H. Conigrave" = c("IPPE", "UQ"),
"Michael Noetel" = c("UQ", "IPPE")
),
affiliations = list("IPPE" = "Institute for Postitive Psychology and Education",
"UQ" = "University of Queensland"),
corres_email = "james@conigrave.com",
corres_address = "33 Berry Street, North Sydney, NSW, Australia",
corres_name = "James H. Conigrave"
)

matches <- gregexpr("(?<=affiliation : \")\\d+(,\\d+)*", text, perl=TRUE)

all_affiliations <- regmatches(text, matches)[[1]]

# Get the second instance
second_affiliation <- all_affiliations[2]
expect_equal("2,1", second_affiliation)

})