| format_column_names | R Documentation |
The format_column_names() function formats a vector of
strings to be used as columns' names for a table in a SQLite
database.
format_column_names(
x,
quote_method = "DB_NAMES",
unique_names = TRUE,
encoding = ""
)
x |
character vector with the identifiers' names to be quoted. |
quote_method |
character, used to specify how to build the SQLite
columns' names from the identifiers passed through the
|
unique_names |
logical, checks for any duplicate name after
applying the selected quote methods. If duplicates exist, they
will be made unique by adding a postfix |
encoding |
character, encoding to be assumed for input strings. It is used to re-encode the input in order to process it to build column identifiers. Defaults to ‘""’ (for the encoding of the current locale). |
A data frame containing the columns' identifiers in two formats:
quoted: the quoted names, as per the selected quote_method;
unquoted: the cleaned names, without any quoting.
# Example with DB_NAMES method
col_names <- c("column 1", "column-2", "3rd_column", "SELECT")
formatted_names <- format_column_names(col_names, quote_method = "DB_NAMES")
print(formatted_names)
# Example with SINGLE_QUOTES method
formatted_names_sq <- format_column_names(col_names, quote_method = "SINGLE_QUOTES")
print(formatted_names_sq)
# Example with SQL_SERVER method
formatted_names_sqlsrv <- format_column_names(col_names, quote_method = "SQL_SERVER")
print(formatted_names_sqlsrv)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.