ropensci / rfishbase
Showing 3 of 5 files from the diff.

@@ -199,7 +199,7 @@
Loading
199 199
  ecosys <- fb_tbl("ecosystem", server, version, db) %>% fix_ids()
200 200
  e_code <- dplyr::collect(ecosysname)$E_CODE
201 201
  out <- dplyr::filter(ecosys, E_CODE == e_code)
202 -
  species <- dplyr::select(load_taxa(server, version, db), "SpecCode", "Species")
202 +
  species <- dplyr::select(load_taxa(server, version, db, collect=FALSE), "SpecCode", "Species")
203 203
  out <- left_join(out, species, by = "SpecCode")
204 204
  out <- left_join(out, dplyr::select(ecosysref, E_CODE, EcosystemName),
205 205
    by = "E_CODE")

@@ -6,12 +6,15 @@
Loading
6 6
#' latest avialable; see [available_releases()].
7 7
#' @param db A remote database connection. Will default to the best available
8 8
#' system, see [default_db()].
9 +
#' @param collect return a data.frame if TRUE, otherwise, a DBI connection to
10 +
#'  the table in the database
9 11
#' @param ... for compatibility with previous versions
10 12
#' @return the taxa list
11 13
#' @export
12 14
load_taxa <- function(server = getOption("FISHBASE_API", "fishbase"), 
13 15
                      version = get_latest_release(),
14 16
                      db = default_db(),
17 +
                      collect = TRUE,
15 18
                      ...){
16 19
  
17 20
  db_tbl <- tbl_name("taxa",  server, version)
@@ -20,11 +23,16 @@
Loading
20 23
  ## SeaLifeBase requires a different taxa table function:
21 24
  if(is.null(server)) server <- getOption("FISHBASE_API", FISHBASE_API)
22 25
  if(grepl("sealifebase", server)){
23 -
    slb_taxa_table(server, version, db)
26 +
    taxa_table <- slb_taxa_table(server, version, db)
24 27
  } else {
25 -
    fb_taxa_table(server, version, db)
28 +
    taxa_table<- fb_taxa_table(server, version, db)
26 29
  }
30 +
  
31 +
  if(collect) return(dplyr::collect(taxa_table))
32 +
  
33 +
  taxa_table
27 34
}
35 +
28 36
  
29 37
30 38
@@ -75,8 +83,9 @@
Loading
75 83
    #dplyr::select(-tempcolumn) %>%
76 84
    #dplyr::arrange(SpecCode) %>% 
77 85
    dplyr::compute(tbl_name("taxa", server, version), temporary=FALSE)
86 +
  taxa_table
78 87
  
79 -
  dplyr::collect(taxa_table)
88 +
80 89
}
81 90
82 91

@@ -36,7 +36,7 @@
Loading
36 36
                           db = default_db()){
37 37
38 38
  ## load_taxa provides "Genus species"-style species names for a consistent interface
39 -
  species <- load_taxa(server, version, db) %>% 
39 +
  species <- load_taxa(server, version, db, collect=FALSE) %>% 
40 40
    dplyr::select("SpecCode", "Species")
41 41
  
42 42
  ## "Species" in many tables is just the epithet, we want full species name so drop that.
@@ -105,7 +105,7 @@
Loading
105 105
                       version = get_latest_release(),
106 106
                       db = default_db(), 
107 107
                       ...){
108 -
  load_taxa(server, version, db, ...) %>% dplyr::select("SpecCode", "Species")
108 +
  load_taxa(server, version, db, collect = FALSE, ...) %>% dplyr::select("SpecCode", "Species")
109 109
}
110 110
111 111
Files Coverage
R 83.28%
Project Totals (14 files) 83.28%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 3%
9
    patch:
10
      default:
11
        target: auto
12
        threshold: 3%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading