AgrDataSci / ClimMobTools

@@ -124,7 +124,23 @@
Loading
124 124
#' .pluralize(zz)
125 125
#' @noRd
126 126
.pluralize <- function(x, p = "s") {
127 -
  paste0(x, p)
127 +
  
128 +
  pl <- matrix(c("variety","varieties",
129 +
                 "variedad","variedades",
130 +
                 "opcion", "optiones"), 
131 +
               nrow = 3, ncol = 2, byrow = TRUE)
132 +
  
133 +
  is_here <- x %in% pl[,1]
134 +
  if (isTRUE(is_here)) {
135 +
    x <- pl[pl[,1] %in% x, 2]
136 +
  }
137 +
  
138 +
  if (isFALSE(is_here)) {
139 +
    x <- paste0(x, p)
140 +
  }
141 +
  
142 +
  return(x)
143 +
  
128 144
}
129 145
130 146
#' Decode arguments from ClimMob3
@@ -210,4 +226,3 @@
Loading
210 226
  return(result)
211 227
  
212 228
}
213 -

@@ -8,7 +8,7 @@
Loading
8 8
#' @author Kauê de Sousa
9 9
#' @param project a character for the project id
10 10
#' @param as.data.frame logical, to return a data frame
11 -
#' @param ... additional arguments passed to methods
11 +
#' @param ... additional arguments passed to methods. See details
12 12
#' @inheritParams getProjectsCM
13 13
#' @return An object of class 'CM_list' or a data.frame with class "CM_df" with the 
14 14
#' variables:
@@ -16,6 +16,12 @@
Loading
16 16
#' \item{moment}{the data collection moment}
17 17
#' \item{variable}{the variable name}
18 18
#' \item{value}{the value for each variable}
19 +
#' @details 
20 +
#' Additional arguments: 
21 +
#' 
22 +
#' \code{server}: a character to select from which server the data will be retrieved, either 
23 +
#'  "prodution" (the default) or "testing"
24 +
#' 
19 25
#' @examples
20 26
#' \dontrun{
21 27
#' 
@@ -38,7 +44,24 @@
Loading
38 44
                      project = NULL, 
39 45
                      as.data.frame = TRUE, ...){
40 46
  
41 -
  url <- "https://climmob.net/climmob3/api/readDataOfProject?Body={}&Apikey={}"
47 +
  dots <- list(...)
48 +
  server <- dots[["server"]]
49 +
  
50 +
  if (is.null(server)) {
51 +
    server <- "production"
52 +
  }
53 +
  
54 +
  if (server == "production") {
55 +
    
56 +
    url <- "https://climmob.net/climmob3/api/readDataOfProject?Body={}&Apikey={}"
57 +
    
58 +
  }
59 +
  
60 +
  if (server == "testing") {
61 +
    
62 +
    url <- "https://testing.climmob.net/climmob3/api/readDataOfProject?Body={}&Apikey={}"
63 +
    
64 +
  }
42 65
  
43 66
  cmdata <- httr::RETRY(verb = "GET", 
44 67
                        url = url,

@@ -6,6 +6,7 @@
Loading
6 6
#' @family GET functions
7 7
#' @param key a character for the user's application programming 
8 8
#'  interface (API) key
9 +
#' @param ... additional arguments passed to methods. See details
9 10
#' @return A data frame with the ClimMob projects 
10 11
#' \item{project_id}{the project unique id}
11 12
#' \item{name}{the project name}
@@ -17,6 +18,13 @@
Loading
17 18
#'  which were registered}
18 19
#' \item{last_registration_activity}{number of days since the submission 
19 20
#'  of the last registration}
21 +
#' 
22 +
#' @details 
23 +
#' Additional arguments: 
24 +
#' 
25 +
#' \code{server}: a character to select from which server the data will be retrieved, either 
26 +
#'  "prodution" (the default) or "testing"
27 +
#'  
20 28
#' @examples
21 29
#' \dontrun{ 
22 30
#' # This function will not work without an API key  
@@ -31,9 +39,26 @@
Loading
31 39
#' 
32 40
#' @seealso ClimMob website \url{https://climmob.net/}
33 41
#' @export
34 -
getProjectsCM <- function(key = NULL){
42 +
getProjectsCM <- function(key = NULL, ...){
43 +
  
44 +
  dots <- list(...)
45 +
  server <- dots[["server"]]
46 +
  
47 +
  if (is.null(server)) {
48 +
    server <- "production"
49 +
  }
50 +
  
51 +
  if (server == "production") {
52 +
    
53 +
    url <- "https://climmob.net/climmob3/api/readProjects?Apikey="
54 +
    
55 +
  }
35 56
36 -
  url <- "https://climmob.net/climmob3/api/readProjects?Apikey="
57 +
  if (server == "testing") {
58 +
    
59 +
    url <- "https://testing.climmob.net/climmob3/api/readProjects?Apikey="
60 +
    
61 +
  }
37 62
  
38 63
  dat <- httr::RETRY(verb = "GET",
39 64
                     url = url,
Files Coverage
R 67.58%
Project Totals (7 files) 67.58%
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