Skip to content

Commit

Permalink
remove deprecated code, fix: https to http for emof join to work
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenpp7 committed Jul 27, 2023
1 parent 1f85a4d commit 712ec90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
23 changes: 14 additions & 9 deletions R/checkdataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ checkdataset = function(Event = NULL, Occurrence = NULL, eMoF = NULL, IPTreport

if ( exists("Occurrence") == TRUE ) {

if (!is.null(Occurrence)){

if(!"occurrenceID" %in% names(Occurrence) & "id" %in% names(Occurrence)) {
warning("There is no occurrenceID field in the Occurrence table; occurrenceID created from id field")
Occurrence <- Occurrence %>% mutate(occurrenceID = id)
}

Occurrence <- Occurrence %>% cleandataframe()

}
}}

# Occurrence <- Occurrence %>% mutate_all(na_if, 'NA') %>%
# mutate_all(na_if, '') %>%
Expand Down Expand Up @@ -110,16 +112,19 @@ checkdataset = function(Event = NULL, Occurrence = NULL, eMoF = NULL, IPTreport

eMoF <- eMoF %>% cleandataframe()

# eMoF <- eMoF %>% mutate_all(na_if, 'NA') %>%
# mutate_all(na_if, '') %>%
# mutate_all(na_if, ' ')
# eMoF <- eMoF[,colSums(is.na(eMoF))<nrow(eMoF)]

eMoF <- fncols(eMoF, c("occurrenceID", "measurementType", "measurementTypeID","measurementValueID", "measurementValue", "measurementUnitID", "eventID", "measurementUnit"))
# eMoF[eMoF =='NA' | eMoF =='' | eMoF ==' '] <- NA


eMoF <- eMoF %>% mutate (measurementTypeID = if_else(str_sub(measurementTypeID, -1, -1)=='/',measurementTypeID, paste(measurementTypeID, "/", sep = '')),
measurementValueID = if_else(str_sub(measurementValueID, -1, -1)=='/',measurementValueID, paste(measurementValueID, "/", sep = '')),
measurementUnitID = if_else(str_sub(measurementUnitID, -1, -1)=='/',measurementUnitID, paste(measurementUnitID, "/", sep = '')),
measurementTypeID = str_replace(measurementTypeID, "https://", "http://"),
measurementValueID = str_replace(measurementValueID, "https://", "http://"),
measurementUnitID = str_replace(measurementUnitID, "https://", "http://")

)

eMoF <- eMoF %>% mutate (measurementTypeID = if_else(str_sub(measurementTypeID, -1, -1)=='/',measurementTypeID, paste(measurementTypeID, "/", sep = '') ),
measurementValueID = if_else(str_sub(measurementValueID, -1, -1)=='/',measurementValueID, paste(measurementValueID, "/", sep = ''))
)

if ( exists("Event") == TRUE){
if(!is.null(eMoF$eventID) == FALSE){
Expand Down
5 changes: 3 additions & 2 deletions R/smallfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,19 @@ leftfrom <- function(x, y, n = 0) {

cleandataframe <- function (x, vector = TRUE) {

# format to ISO 8601 if class POSIXct
for (field in colnames(x)){
if(TRUE %in% (class(x[[field]]) == "POSIXct")){
x[[field]] <- format_iso_8601(x[[field]])
}
# format to ISO 8601 if class POSIXct
}

# turn character NAs and spaces into an actual empty cell
x <- x %>% mutate(across(where(is.character), ~na_if(., "NA"))) %>%
mutate(across(where(is.character), ~na_if(., ""))) %>%
mutate(across(where(is.character), ~na_if(., " ")))


# remove empty columns
x <- x[,colSums(is.na(x))<nrow(x)]

if (vector == TRUE ){
Expand Down

0 comments on commit 712ec90

Please sign in to comment.