Description Usage See Also Examples
summarize_field
gets the total rows, distinct value count, valueset, and null counts for a single field in a table. To get the summary of more than 1 field, see summarize_fields
. To summarize an entire table or schema without hand-selecting fields, see summarize_table
and summarize_schema
respectively.
1 2 3 4 5 6 7 8 9 10 11 12 |
Other summary functions:
summarize_fields()
,
summarize_schema()
,
summarize_table()
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | library(pg13)
create_test_schema <-
function(conn) {
if (!schema_exists(conn = conn,
schema = "test_schema")) {
cli::cli_rule("Create 'test_schema' Schema")
create_schema(conn = conn,
schema = "test_schema")
}
}
conn <- local_connect(dbname = "pg13_test")
create_test_schema(conn = conn)
write_table(conn = conn,
schema = "test_schema",
table_name = "test_table",
drop_existing = TRUE,
data = data.frame(A = 1:3, B = letters[1:3]))
write_table(conn = conn,
schema = "test_schema",
table_name = "test_table2",
drop_existing = TRUE,
data = data.frame(C = rep(NA, 3), D = c(TRUE, FALSE, FALSE)))
write_table(conn = conn,
schema = "test_schema",
table_name = "test_table3",
drop_existing = TRUE,
data = data.frame(E = c(1.25, 343.31341, 5),
G = c(Sys.Date(), Sys.Date()-100, Sys.Date()-1000)))
summarize_fields(conn = conn, schema = "test_schema", table = "test_table", fields = c("A", "B"))
# Case is ignored
summarize_fields(conn = conn, schema = "test_schema", table = "test_table", fields = c("a", "b"))
summarize_fields(conn = conn, schema = "test_schema", table = "test_table2", fields = c("c", "D"))
# To summarize an entire table (all the fields without manually inputting them)
summarize_table(conn = conn, schema = "test_schema", table = "test_table3")
# An entire schema can also be summarized
summarize_schema(conn = conn, schema = "test_schema")
drop_schema(conn = conn,
schema = "test_schema",
cascade = TRUE)
dc(conn = conn)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.