Skip to content

Instantly share code, notes, and snippets.

View Athospd's full-sized avatar
🏠
Working from home

Athos Petri Damiani Athospd

🏠
Working from home
View GitHub Profile
@jjesusfilho
jjesusfilho / pg_pivot_wider.R
Last active January 18, 2024 11:28
Converts PostgreSQL table from long to wide format from R
#' Converts PostgreSQL table from long to wide format
#'
#' @param conn Connection
#' @param tbl Table
#' @param new_tbl Optional. It creates a new table in the database
#' instead of importing it to R
#' @param id_cols String vector with the name of columns to be used as identities
#' @param names_from Column whose values will become variables
#' @param values_from Column whose values will populate the new variables
#'