View source: R/multiple_entries.R
fhir_cast | R Documentation |
fhir_crack()
into separate columns.This function turns a table from compact format into wide format. Every column containing multiple entries will be turned into multiple columns. The number of columns created from a single column in the original table is determined by the maximum number of multiple entries occurring in this column. Rows with less than the maximally occurring number of entries will be filled with NA values.
fhir_cast(indexed_df, brackets, sep, verbose = 1)
indexed_df |
A compact data.frame/data.table with indexed multiple entries. Column names should reflect the XPath expression of the respective element. |
brackets |
A character vector of length two, defining the brackets used for the indices. |
sep |
A character vector of length one defining the separator that was used when pasting together multiple entries in |
verbose |
An integer vector of length one. If 0, nothing is printed, if 1, only general progress is printed, if > 1, progress for each variable is printed. Defaults to 1. |
For fhir_cast()
to work properly, column names of the input data must reflect the Xpath to the corresponding resource element
with .
as a separator, e.g. code.coding.system
. These names are produced automatically by fhir_crack()
when the names are not explicitly set in the cols
element of the fhir_table_description()
/fhir_design()
.
In the names of the newly created columns the indices will be added in front of the column names, similar to the result of fhir_crack()
with
format="wide"
. See examples and the corresponding package vignette for a more detailed description.
fhir_crack()
, fhir_melt()
, fhir_build_bundle()
#unserialize example
bundles <- fhir_unserialize(bundles = example_bundles1)
#crack fhir resources
table_desc <- fhir_table_description(
resource = "Patient",
brackets = c('[', ']'),
sep = " ",
keep_attr=TRUE
)
df <- fhir_crack(bundles = bundles, design = table_desc)
#original df
df
#cast
fhir_cast(df, brackets=c('[', ']'), sep = ' ', verbose = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.