-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 new function colcompare #9
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b7f891b
create colcompare
SanderDevisscher c4ee29c
Create rds
SanderDevisscher 8f37cff
Delete scafold.txt
SanderDevisscher 21f0e49
Update DESCRIPTION
SanderDevisscher 4e684d6
update function
SanderDevisscher 7544f08
fix remaining errors & warnings
SanderDevisscher fd41321
Update check.R
soriadelva 16c6325
fix check
SanderDevisscher 66e601f
Update check.Rd
SanderDevisscher 37778b1
Update check.R
SanderDevisscher efcb1f6
Update check.Rd
SanderDevisscher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
importFrom(magrittr,"%>%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' Check | ||
#' | ||
#' @author Sander Devisscher | ||
#' | ||
#' @description | ||
#' Helper script to determine existance in environment panel | ||
#' | ||
#' @param x environment object | ||
#' | ||
#' @returns | ||
#' 1 = object exists in enviroment | ||
#' 0 = object doesn't exist in enviroment | ||
|
||
|
||
check <- function(x){tryCatch(if(is.logical(class(x))) 1 else 1, error=function(e) 0)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#' Columnname comparison | ||
#' | ||
#' @author Sander Devisscher | ||
#' | ||
#' @description | ||
#' A simple function to list the difference in column names in 2 datasets. | ||
#' | ||
#' @param x dataframe 1 | ||
#' @param y dataframe 2 | ||
#' | ||
#' @return | ||
#' a list of columns present in x but not in y and a list of columns | ||
#' present in y and not in x. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # create example dataframes | ||
#' super_sleepers <- data.frame(rating=1:4, | ||
#' animal=c('koala', 'hedgehog', 'sloth', 'panda'), | ||
#' country=c('Australia', 'Italy', 'Peru', 'China'), | ||
#' avg_sleep_hours=c(21, 18, 17, 10)) | ||
#' | ||
#' super_actives <- data.frame(rating=1:4, | ||
#' animal=c('kangeroo', 'wolf', 'jaguar', 'tiger'), | ||
#' country=c('Australia', 'Italy', 'Peru', 'China'), | ||
#' avg_active_hours=c(16, 15, 8, 10)) | ||
#' | ||
#' colcompare(super_sleepers, super_actives) | ||
#' } | ||
#' | ||
#' @importFrom magrittr %>% | ||
|
||
colcompare <- function(x, y){ | ||
|
||
test_xiny <- subset(colnames(x), !colnames(x) %in% colnames(y)) | ||
test_xiny <- as.data.frame(test_xiny) %>% | ||
dplyr::mutate(lower = tolower(test_xiny)) | ||
test_yinx <- subset(colnames(y), !colnames(y) %in% colnames(x)) | ||
test_yinx <- as.data.frame(test_yinx) %>% | ||
dplyr::mutate(lower = tolower(test_yinx)) | ||
|
||
combined <- test_xiny %>% | ||
dplyr::full_join(test_yinx, by = "lower") | ||
|
||
# Typos (x en y) #### | ||
test_xANDy <- combined %>% | ||
dplyr::filter(!is.na(test_xiny) & !is.na(test_yinx)) %>% | ||
dplyr::mutate(test_xANDy = paste0("X: ", test_xiny, " <==> ", test_yinx, " :Y \n")) | ||
test_xANDy <- test_xANDy$test_xANDy | ||
|
||
if(check(test_xANDy) == 1){ | ||
if(!rlang::is_empty(test_xANDy)){ | ||
error <- paste0("Kolommen met verschillende schrijfwijze: \n", | ||
test_xANDy) | ||
writeLines(error) | ||
print("=====================================================================") | ||
} | ||
} | ||
# Only X #### | ||
test_xiny <- combined %>% | ||
dplyr::filter(is.na(test_yinx)) | ||
test_xiny <- test_xiny$test_xiny | ||
|
||
if(check(test_xiny)==1){ | ||
if(!rlang::is_empty(test_xiny)){ | ||
test_xiny <- paste(test_xiny, collapse = ", \n") | ||
error <- paste0("Kolommen uit x die niet in y voorkomen: \n", test_xiny) | ||
writeLines(error) | ||
print("=====================================================================") | ||
} | ||
} | ||
|
||
# Only y #### | ||
test_yinx <- combined %>% | ||
dplyr::filter(is.na(test_xiny)) | ||
test_yinx <- test_yinx$test_yinx | ||
|
||
if(check(test_yinx)==1){ | ||
if(!rlang::is_empty(test_yinx)){ | ||
test_yinx <- paste(test_yinx, collapse = ", \n") | ||
error <- paste0("Kolommen uit y die niet in x voorkomen: ", test_yinx) | ||
writeLines(error) | ||
} | ||
} | ||
} |
Empty file.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do check(t) it still returns 1, even though I don't have t in my environment, is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's not correct no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ik blijf dat probleem precies hebben 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ook met een aantal andere random dingen bvb check(de), check(longley), check(t) die yielden allemaal 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heb je branch terug binnengehaald ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ja ,fetched en pulled, heb jij dat probleem niet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be fixed now