Skip to content

Commit edf5e27

Browse files
authored
Merge pull request #53 from thiloshon/master
Final CRAN version
2 parents f75eef6 + b69a450 commit edf5e27

40 files changed

+1041
-814
lines changed

.Rbuildignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
^codecov\.yml$
2+
^appveyor\.yml$
13
^cran-comments\.md$
24
^CRAN-RELEASE$
35
^.*\.Rproj$
46
^\.Rproj\.user$
57
^\.travis\.yml$
68
^\.idea$
79
^img$
10+
^\.gitignore$
11+
^\.Rhistory$
12+
^\.RData$
13+
^\.gitattributes$

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto
2+
data/* binary
3+
src/* text=lf
4+
R/* text=lf

.travis.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,17 @@
22

33
language: R
44
sudo: false
5-
cache: packages
5+
cache: packages
6+
7+
r:
8+
- oldrel
9+
- release
10+
- devel
11+
12+
r_check_args: "--as-cran"
13+
14+
r_packages:
15+
- covr
16+
17+
after_success:
18+
- Rscript -e 'library(covr); codecov()'

CRAN-RELEASE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This package was submitted to CRAN on 2019-04-10.
2+
Once it is accepted, delete this file and tag the release (commit 1faa2f9a78).

DESCRIPTION

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Package: bdclean
22
Type: Package
33
Title: A User-Friendly Biodiversity Data Cleaning App for the Inexperienced R User
4-
Description: Provides features to manage complete work flow for biodiversity data cleaning, from uploading the data; gathering input from the user, in order to adjust cleaning procedures; perform the cleaning; and finally, generating various reports and several versions of the data. Facilitates user-level data cleaning, designed for the inexperienced R user. T Gueta et al (2018) <doi:10.3897/biss.2.25564>. T Gueta et al (2017) <doi:10.3897/tdwgproceedings.1.20311>.
5-
Version: 0.1.12
6-
Date: 2019-03-02
4+
Description: Provides features to manage the complete workflow for biodiversity data cleaning. Uploading data, gathering input from users (in order to adjust cleaning procedures), cleaning data and finally, generating various reports and several versions of the data. Facilitates user-level data cleaning, designed for the inexperienced R user. T Gueta et al (2018) <doi:10.3897/biss.2.25564>. T Gueta et al (2017) <doi:10.3897/tdwgproceedings.1.20311>.
5+
Version: 0.1.15
6+
Date: 2019-04-10
77
License: GPL-3
88
URL: https://github.com/bd-R/bdclean, https://bd-r.github.io/The-bdverse/index.html
99
BugReports: https://github.com/bd-R/bdclean/issues
@@ -42,5 +42,7 @@ Imports: rmarkdown, knitr, shiny, shinydashboard, shinyjs, leaflet, DT, data.tab
4242
Depends: R (>= 2.10)
4343
RoxygenNote: 6.1.1
4444
Suggests:
45-
testthat
45+
testthat,
46+
roxygen2,
47+
covr
4648
LazyData: true

NAMESPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ export(clean_data)
66
export(cleaning_function)
77
export(create_default_questionnaire)
88
export(create_report_data)
9-
export(earliestDate)
9+
export(earliest_date)
1010
export(get_checks_list)
1111
export(run_bdclean)
1212
export(run_questionnaire)
13-
export(spatialResolution)
14-
export(taxoLevel)
15-
export(temporalResolution)
13+
export(spatial_resolution)
14+
export(taxo_level)
15+
export(temporal_resolution)
1616
import(bdDwC)
1717
import(bdchecks)
1818
import(data.table)

R/bdclean.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
#' in order to achieve minimum quality to use the data further for any
99
#' analysis or modelling.
1010
#'
11-
#'@section Data cleaning:
12-
#'\itemize{
13-
#'\item \link{run_bdclean}
14-
#'\item \link{clean_data}
15-
#'}
11+
#' @section Data cleaning:
12+
#' \itemize{
13+
#' \item \link{run_bdclean}
14+
#' \item \link{clean_data}
15+
#' }
1616
#'
1717
#'
18-
#'@section Citation:
19-
#'\itemize{
20-
#'\item Gueta, T., Barve, V., Nagarajah, T., Agrawal, A. & Carmel, Y. (2018). bdclean: Biodiversity data cleaning workflows (R package V 1.0.0). Retrieved from https://github.com/bd-R/bdclean/
21-
#'}
18+
#' @section Citation:
19+
#' \itemize{
20+
#' \item Gueta, T., Barve, V., Nagarajah, T., Agrawal, A. & Carmel, Y. (2019). bdclean: Biodiversity data cleaning workflows (R package V 0.1.13). Retrieved from https://github.com/bd-R/bdclean/
21+
#' }
2222
#'
2323
#' @docType package
2424
#' @name bdclean

R/clean_data.R

Lines changed: 73 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -7,156 +7,152 @@
77
#' You can add your custom questions to this questionnaire and then pass it to this
88
#' function to process the data.
99
#'
10-
#'@param data Biodiversity data in a data frame
11-
#'@param customQuestionnaire Custom user created questionnaire responses if to pypass answering questions each time.
12-
#'@param clean Whether to clean after flagging. If false only flagging will be done.
13-
#'@param missing How to treat data with missing values. Default: false - will be treated as bad data.
14-
#'@param report Whether to print report of cleaning done.
15-
#'@param format Formats of the cleaning report required. Options are: Markdown, HTML or / and PDF
10+
#' @param data Biodiversity data in a data frame
11+
#' @param custom_questionnaire Custom user created questionnaire responses if to pypass answering questions each time.
12+
#' @param clean Whether to clean after flagging. If false only flagging will be done.
13+
#' @param missing How to treat data with missing values. Default: false - will be treated as bad data.
14+
#' @param report Whether to print report of cleaning done.
15+
#' @param format Formats of the cleaning report required. Options are: Markdown, HTML or / and PDF
1616
#'
17-
#'@return data frame with clean data
17+
#' @return data frame with clean data
1818
#'
19-
#'@examples \dontrun{
20-
#'library(rgbif)
21-
#'occdat <- occ_data(
22-
#' country = "AU", # Country code for australia
23-
#' classKey= 359, # Class code for mammalia
24-
#' limit=5000 # Get only 5000 records
25-
#' )
26-
#' myData<-occdat$data
27-
#'
28-
#' cleanedData <- clean_data(myData)
29-
#'
30-
#' responses <- run_questionnaire()
31-
#' cleanedData <- clean_data(myData, responses)
32-
#'
33-
#' customQuestionnaire <- create_default_questionnaire()
34-
#' customResponses <- run_questionnaire(customQuestionnaire)
35-
#' cleanedData <- clean_data(myData, customResponses)
36-
#' }
19+
#' @examples
20+
#'
21+
#' custom_questionnaire <- create_default_questionnaire()
22+
#'
23+
#' if(interactive()){
24+
#'
25+
#' library(rgbif)
26+
#' occdat <- occ_data(
27+
#' country = 'AU', # Country code for australia
28+
#' classKey = 359, # Class code for mammalia
29+
#' limit = 50 # Get only 50 records
30+
#' )
31+
#' myData <- occdat$data
32+
#'
33+
#' responses <- run_questionnaire()
34+
#' cleaned_data <- clean_data(myData, responses)
35+
#'
36+
#' cleaned_data2 <- clean_data(myData)
37+
#'
38+
#' }
3739
#'
38-
#'@export
40+
#' @export
3941
clean_data <-
4042
function(data,
41-
customQuestionnaire = NULL,
43+
custom_questionnaire = NULL,
4244
clean = TRUE,
4345
missing = FALSE,
4446
report = TRUE,
4547
format = c("html_document", "pdf_document")) {
4648
responses <- list()
47-
inputData <- data
48-
flaggedData <- data
49-
cleanedData <- data
50-
49+
input_data <- data
50+
flagged_data <- data
51+
cleaned_data <- data
5152

5253
# Questionnaire
53-
if (is.null(customQuestionnaire)) {
54+
if (is.null(custom_questionnaire)) {
5455
responses <- run_questionnaire()
5556
} else {
56-
responses <- customQuestionnaire
57+
responses <- custom_questionnaire
5758
}
5859

5960
# Flagging
60-
flaggedData <- responses$flagData(inputData, missing)
61-
61+
flagged_data <- responses$flag_data(input_data, missing)
6262

6363
# Decision Making
6464
if (clean) {
65-
cleanedData <- cleaning_function(flaggedData)
65+
cleaned_data <- cleaning_function(flagged_data)
6666
}
6767

6868
# Report
6969
if (report) {
7070
create_report_data(data,
71-
flaggedData,
72-
cleanedData,
71+
flagged_data,
72+
cleaned_data,
7373
responses,
7474
clean,
7575
format)
7676
}
7777

7878
# Cleaning
7979
if (clean) {
80-
return(cleanedData)
80+
return(cleaned_data)
8181
}
8282

83-
return(flaggedData)
83+
return(flagged_data)
8484
}
8585

8686

8787
#' Execute the Questionnaire and save user responses.
8888
#'
8989
#'
90-
#'@param customQuestionnaire Custom User Created Questionnaire if already available.
90+
#' @param custom_questionnaire Custom User Created Questionnaire if already available.
9191
#'
92-
#'@return list with BdQuestionObjects containing user answers
92+
#' @return list with BdQuestionObjects containing user answers
9393
#'
94-
#'@examples \dontrun{
95-
#'library(rgbif)
96-
#'occdat1 <- occ_data(
97-
#' country = "AU", # Country code for australia
98-
#' classKey= 359, # Class code for mammalia
99-
#' limit=5000, # Get only 5000 records
100-
#' )
101-
#' myData<-occdat1$data
94+
#' @examples
95+
#'
96+
#' if(interactive()){
10297
#'
103-
#' responses <- run_questionnaire()
104-
#' cleanedData <- clean_data_new(myData, responses)
105-
#'}
98+
#' responses <- run_questionnaire()
99+
#'
100+
#' }
106101
#'
107-
#'@export
108-
run_questionnaire <- function(customQuestionnaire = NULL) {
102+
#' @export
103+
run_questionnaire <- function(custom_questionnaire = NULL) {
109104
responses <- list()
110-
111-
if (is.null(customQuestionnaire)) {
105+
if (is.null(custom_questionnaire)) {
112106
message("Custom Questionnaire not given. Using package default Questionnaire...")
113107
responses <- create_default_questionnaire()
114-
115108
} else {
116-
if (class(customQuestionnaire) != "BdQuestionContainer") {
109+
if (class(custom_questionnaire) != "BdQuestionContainer") {
117110
message(
118111
"Provided Custom Questionnaire is not of class BdQuestionContainer.
119112
Using package default Questionnaire"
120113
)
121114
responses <- create_default_questionnaire()
122-
123115
} else {
124116
message("Custom Questionnaire detected.")
125-
responses <- customQuestionnaire
117+
responses <- custom_questionnaire
126118
}
127119
}
128-
129120
message("Please answer the following questions to initiate cleaning process.")
130-
131-
for (question in responses$BdQuestions) {
121+
for (question in responses$bdquestions) {
132122
if (question$question.type != "Child" &&
133123
question$question.type != "ChildRouter") {
134-
getUserResponse(question)
124+
get_user_response(question)
135125
}
136126
}
137127
message("Thank you! Cleaning can be started now based on your responses.")
138128
return(responses)
139129
}
140130

141131
#' Internal function for getting user response
132+
#'
133+
#' @param bd_question The BDQuestion object to get users responses.
134+
#'
135+
#' @examples
142136
#'
143-
#'@param bdQuestion The BDQuestion object to get users responses.
137+
#' if(interactive()){
138+
#'
139+
#' question <- BdQuestion()
140+
#' responses <- get_user_response(question)
144141
#'
145-
getUserResponse <- function(bdQuestion) {
142+
#' }
143+
get_user_response <- function(bd_question) {
146144
# Child & ChildRouter already filtered in first loop above
147-
148-
if (bdQuestion$question.type == "Atomic") {
145+
if (bd_question$question.type == "Atomic") {
149146
# Atomic is filtered
150-
bdQuestion$printQuestion()
151-
bdQuestion$getResponse()
152-
147+
bd_question$print_question()
148+
bd_question$get_response()
153149
} else {
154150
# Router , Child as child & ChildRouter as child is filtered
155-
bdQuestion$printQuestion()
156-
bdQuestion$getResponse()
157-
if (bdQuestion$users.answer %in% bdQuestion$router.condition) {
158-
for (question in bdQuestion$child.questions) {
159-
getUserResponse(question)
151+
bd_question$print_question()
152+
bd_question$get_response()
153+
if (bd_question$users.answer %in% bd_question$router.condition) {
154+
for (question in bd_question$child.questions) {
155+
get_user_response(question)
160156
}
161157
}
162158
}

0 commit comments

Comments
 (0)