We're analyzing columns from our SQL Server environment. We're pulling column names and data types. Then we're running a simple pipe argument to see if we have mixed data types for the same column names across disparate tables.
library(tidyverse)
DF = data.frame(COLUMN_NAME = c("PARTYID","PARTYID","AGE","AGE","SALESID","SALES"),
DATA_TYPE = c("char","tinyint","int","smallint","varchar","numeric"))
DF %>% group_by(COLUMN_NAME) %>%
summarise(mixedTypes = (any(grepl("char", DATA_TYPE)) &
!(all(grepl("char", DATA_TYPE)))))
All I'm getting back is
mixedTypes
1 TRUE
But I believe I should be getting back a subset of the data.frame, including both columns with a new column called mixedTypes
.
UPDATE: Someone suggested using conflicts
and I'm not educated enough to understand how to interpret the detail=TRUE
output:
$.GlobalEnv
[1] "df"
$`package:forcats`
[1] "%>%" "%>%" "%>%" "%>%" "%>%"
$`package:purrr`
[1] "%>%" "%>%" "compact" "%>%" "%>%" "set_names" "%>%"
$`package:tidyr`
[1] "%>%" "%>%" "%>%" "%>%" "extract" "%>%"
$`package:plyr`
[1] "compact" "arrange" "count" "desc" "failwith" "id" "mutate" "rename" "summarise"
[10] "summarize" "is.discrete" "summarize"
$`package:stringr`
[1] "%>%" "%>%" "%>%" "%>%" "%>%"
$`package:tibble`
[1] "add_row" "as_data_frame" "as_tibble" "data_frame" "data_frame_" "frame_data" "glimpse" "lst"
[9] "lst_" "tbl_sum" "tibble" "tribble" "trunc_mat" "type_sum"
$`package:magrittr`
[1] "%>%" "%>%" "%>%" "%>%" "extract" "set_names" "%>%"
$`package:dplyr`
[1] "%>%" "%>%" "%>%" "%>%" "%>%" "add_row" "arrange" "as_data_frame"
[9] "as_tibble" "count" "data_frame" "data_frame_" "desc" "failwith" "frame_data" "glimpse"
[17] "id" "lst" "lst_" "mutate" "rename" "summarise" "summarize" "tbl_sum"
[25] "tibble" "tribble" "trunc_mat" "type_sum" "src" "summarize" "coalesce" "filter"
[33] "lag" "intersect" "setdiff" "setequal" "union"
$`package:Hmisc`
[1] "summarize" "is.discrete" "src" "summarize" "format.pval" "units"
$`package:ggplot2`
[1] "Position"
$`package:MyPackage`
[1] "coalesce" "HeatMap"
$`package:stats`
[1] "df" "filter" "lag"
$`package:methods`
[1] "body<-" "kronecker"
$`package:base`
[1] "body<-" "format.pval" "HeatMap" "intersect" "kronecker" "Position" "setdiff" "setequal" "union"
[10] "units"