Hi! I am having some troubles with the application of glue with some columns that have NULL in it.
Let me present this reprex:
df <- tibble(
a = c(1,2,3,4),
b = c('NULL','x','y','z')
)
a.1 <- colnames(df)
b.1 <- paste(paste0("'{",a.1,"}'"),collapse = ',')
df %>%
mutate(c = glue('(',b.1,')')) %>%
select(c)
This code gives this result:
('1','NULL')
('2','x')
('3','y')
However, I am wondering if is there a way to obtain something like
('1',NULL)
('2','x')
('3','y')
This will allow me to transfer my results to SQL. For that, I have tried to use conditionals inside glue, like ifelse
without results.
Please, any comment will be highly appreciated.
Regards