View source: R/format_invalue.R
| fnew_bid | R Documentation |
Creates both a format and its corresponding invalue for bidirectional conversion.
Both are automatically stored in the global format library if name
is provided.
fnew_bid(..., name = NULL, type = "auto")
... |
Named arguments for format mappings |
name |
Character. Base name for both formats. The invalue will be
named |
type |
Character. Format type |
List with format (ks_format) and invalue (ks_invalue)
components.
# Bidirectional status format
status_bi <- fnew_bid(
"A" = "Active",
"I" = "Inactive",
"P" = "Pending",
name = "status"
)
# Forward: code -> label
fputc(c("A", "I", "P", "A"), "status")
# [1] "Active" "Inactive" "Pending" "Active"
# Reverse: label -> code
finputc(c("Active", "Pending", "Inactive"), "status_inv")
# [1] "A" "P" "I"
fclear()
# From a named vector (Label = Code convention, same as fnew)
fnew_bid(c(Male = "M", Female = "F"), name = "sex_bid")
fputc(c("M", "F"), "sex_bid")
finputc(c("Male", "Female"), "sex_bid_inv")
fclear()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.