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

Check compatibility #94

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
64db845
Trying out map for tests
fontikar Jan 12, 2023
7704303
Added version number to austraits_list_post
fontikar Jan 12, 2023
5e2e6a2
Added Wright_2019 in old rel test dataset so tests are consistent
fontikar Jan 12, 2023
426fc4d
Updated code to subset 4.0.0 from zenodo
fontikar Jan 12, 2023
b677567
Version testing for extract, and summarise_austriats
fontikar Jan 12, 2023
c2008c5
Combined extract_ tests and added version testing
fontikar Jan 12, 2023
5e47cfb
Version tests for join_
fontikar Jan 13, 2023
c0781b5
Version tests for widetable and renamed test files
fontikar Jan 13, 2023
50154e1
#60 fixed imports for pivot_wider, organised tests, currently not wor…
fontikar Jan 13, 2023
247db43
Minor naming adjustments in test
fontikar Jan 13, 2023
2b79ab5
Merge branch 'multi_tests' into develop: All possible tests is run th…
fontikar Jan 13, 2023
82a0f0f
Change some dependencies to imports
dfalster Jan 25, 2023
6e0cb08
Remove helper functions to vignettes
dfalster Jan 25, 2023
8f79aa6
Update deprecated functions
dfalster Jan 25, 2023
30d95cc
Restructure tests to run faster
dfalster Jan 25, 2023
9615ed0
Change GH actions triggers
dfalster Jan 25, 2023
87bdb95
ensure consistent ordering of rows
dfalster Jan 25, 2023
846ba84
Merge branch 'master' into develop
fontikar Oct 16, 2023
3564de0
bumped version number
fontikar Oct 16, 2023
4a534bf
Update to work with latest zenodo API (#81)
dfalster Oct 16, 2023
17de18c
Pulled files we want to develop from change-v5
fontikar Oct 19, 2023
f9c1666
Changes for v5 austraits.build (#78)
fontikar Nov 21, 2023
10791de
Bumped version number and updated news
fontikar Nov 21, 2023
32e5262
Added references to packages
fontikar Nov 21, 2023
a64a360
Updated version for GH steps
fontikar Nov 21, 2023
23a2f7a
Updated v number for GHA
fontikar Nov 21, 2023
147030b
Expanding testing suite to all 3 major versions of AusTraits (#86)
fontikar Nov 22, 2023
2bd66f1
Added codecov yml
fontikar Nov 22, 2023
cc8e8cf
Merge branch 'develop' of https://github.com/traitecoevo/austraits in…
fontikar Nov 22, 2023
d1c6f61
Setting limit for patch cov
fontikar Nov 22, 2023
91c94c4
Merge branch 'master' into develop
fontikar Nov 26, 2023
a541663
bumped version number for dev
fontikar Nov 26, 2023
277a7e5
API related packages to Suggests (#89)
fontikar Nov 27, 2023
9360930
Merge branch 'master' into develop
fontikar Sep 3, 2024
9d32105
Bumped version number
fontikar Sep 3, 2024
17fcb2b
Create check_compatibility.R
ehwenk Sep 3, 2024
d9a6355
additions to check_compatibilty
ehwenk Sep 3, 2024
6a06cc9
Update README.Rmd
ehwenk Sep 3, 2024
3239552
Update check_compatibility.R
ehwenk Sep 3, 2024
0606ea4
add util_list_to_df2
ehwenk Sep 3, 2024
e4cb952
Create test-check_compatibiity.R
ehwenk Sep 3, 2024
696186e
further fixes to check_compatibility
ehwenk Sep 3, 2024
9a9be58
Update test-check_compatibiity.R
ehwenk Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: austraits
Title: Helpful functions to access, summarise and wrangle austraits data
Version: 2.2.3
Version: 3.0.0.9000
Authors@R:
c(person(given = "Daniel",
family = "Falster",
Expand All @@ -22,7 +22,7 @@ Encoding: UTF-8
Language: en
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Depends:
R (>= 4.0.0),
RefManageR
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export(summarise_austraits)
export(summarise_trait_means)
export(trait_pivot_longer)
export(trait_pivot_wider)
export(util_list_to_df2)
import(RefManageR)
importFrom(dplyr,arrange)
importFrom(dplyr,filter)
Expand Down
43 changes: 43 additions & 0 deletions R/check_compatibility.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#' @title Check compatibility
#' @description Function to check whether the data object has been compiled by the traits.build workflow and
#' therefore has a data structure that is appropriate for use with austraits functions.
#' @param austraits dataframe generated by traits build
#'
#' @return logical (T/F) output and messaging for uncompatible versions
#'
#' @examples
#' \dontrun{
#' check_compatibility(austraits)
#' }
#' @author Elizabeth Wenk - e.wenk@unsw.edu.au

check_compatibility <- function(austraits) {

if (is.null(austraits$metadata)) {

compatible <- FALSE

writeLines(sprintf("You are working with AusTraits version 3.0 or earlier. This database structure is unsupported by the current version of this package."))
writeLines(sprintf("Please see https://github.com/traitecoevo/austraits for details on installing old versions."))

} else {

compiled_by_traits.build <-
austraits$metadata$related_identifiers %>%
util_list_to_df2() %>%
filter(relation_type == "isCompiledBy", stringr::str_detect(identifier, "github.com/traitecoevo/traits.build"))

if(is.null(compiled_by_traits.build) | nrow(compiled_by_traits.build) > 0) {
compatible <- TRUE
} else{
compatible <- FALSE

writeLines(sprintf("You are working with AusTraits version 4, which is unsupported by the current version of this package."))
writeLines(sprintf("Please see https://github.com/traitecoevo/austraits for details on installing old versions."))
}

}

invisible(compatible)

}
20 changes: 20 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#' Convert a list of lists to dataframe
#'
#' Convert a list of lists to dataframe; requires that every list have same named elements.
#'
#' @param my_list A list of lists to dataframe
#' @param as_character A logical value, indicating whether the values are read as character
#' @param on_empty Value to return if my_list is NULL, NA or is length == 0, default = NA
#'
#' @export
#' @examples util_list_to_df2(util_df_to_list(dplyr::starwars))
util_list_to_df2 <- function(my_list, as_character = TRUE, on_empty = NA) {

if (is.null(my_list) || any(is.na(my_list)) || length(my_list) == 0)
return(on_empty)

if (as_character)
my_list <- lapply(my_list, lapply, as.character)

dplyr::bind_rows(lapply(my_list, tibble::as_tibble))
}
17 changes: 17 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ Otherwise, for a lightweight installation where dependencies for plotting and th
remotes::install_github("traitecoevo/austraits", upgrade = "ask")
```

In September 2024 austraits functions were revamped to support all [traits.build](https://github.com/traitecoevo/traits.build) compiled databases, rather than being linked to [austraits.build](https://github.com/traitecoevo/austraits.build).

Versions of austraits.build (the AusTraits plant trait database) < 5.0 are no longer supported by the current functions. If you are working with an older version of AusTraits, please install an older version of austraits:

For austraits.build versions 4.2 and older:
```{r setup, results = 'hide', eval = FALSE}
#install.packages("remotes")
remotes::install_github("traitecoevo/austraits@53b637c", dependencies = TRUE, upgrade = "ask")

library(austraits)
```

Note, if you are unsure what version of AusTraits you are working with, run:
```{r setup, results = 'hide', eval = FALSE}
austraits$build_info$version
```


### Take a good look at our vignettes! `r emo::ji("eyes")`

Expand Down
26 changes: 26 additions & 0 deletions man/check_compatibility.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/util_list_to_df2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/testthat/test-check_compatibiity.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
austraits <- list(austraits_3.0.2_lite,
austraits_5.0.0_lite)

test_check_compatibility <- function(austraits){
test_that("check_compatibiity successfully detects if the dataframe is compatible with austraits 3.0", {
expect_silent(check_compatibility(austraits_5.0.0_lite))
expect_true(check_compatibility(austraits_5.0.0_lite))
expect_output(check_compatibility(austraits_3.0.2_lite))
expect_false(check_compatibility(austraits_3.0.2_lite))
})
}
Loading