View source: R/format_invalue.R
| finputn | R Documentation |
Looks up a numeric INVALUE format by name from the global format library and applies it to convert labels to numeric values.
finputn(x, invalue_name)
x |
Character vector of labels to convert |
invalue_name |
Character. Name of a registered INVALUE format. |
Numeric vector
# Create numeric invalue and apply
finput(
"Male" = 1,
"Female" = 2,
name = "sex_inv"
)
finputn(c("Male", "Female", "Male", "Unknown", "Female"), "sex_inv")
# [1] 1 2 1 NA 2
fclear()
# Parse invalue from text and apply
fparse(text = '
INVALUE race_inv
"White" = 1
"Black" = 2
"Asian" = 3
;
')
finputn(c("White", "Black"), "race_inv")
# [1] 1 2
fclear()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.