Depivot a Table
1 2 3 4 5 6 7 8 9 10 11 12 | depivot_table(
conn,
conn_fun,
schema,
table,
names_to_columns,
names_to,
values_to_column,
verbose = TRUE,
render_sql = TRUE,
render_only = FALSE
)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | library(tidyverse)
conn <- pg13::local_connect()
pg13::write_table(conn = conn,
schema = "public",
table_name = "test_table",
drop_existing = TRUE,
data =
tribble(~Person,~Attribute, ~Attribute_Value,
"Meera", "Height", "Tall",
"Syed", "Height", "Tall",
"Syed", "Character", "Funny",
"Meera", "Character", NA_character_))
pivot_table(conn = conn,
schema = "public",
table = "test_table",
id_column = "person",
names_from_column = "attribute",
values_from_column = "attribute_value")
depivot_table(conn = conn,
schema = "public",
table = "test_table",
names_to_columns = "attribute",
names_to = "field",
values_to_column = "attribute_type")
depivot_table(conn = conn,
schema = "public",
table = "test_table",
names_to_columns = c("person", "attribute", "attribute_value"),
names_to = "field",
values_to_column = "attribute_type")
pg13::drop_table(conn = conn,
schema = "public",
table = "test_table")
pg13::dc(conn = conn)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.