-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfhir_melt_all.Rd
95 lines (85 loc) · 2.5 KB
/
fhir_melt_all.Rd
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fhircrack.R
\name{fhir_melt_all}
\alias{fhir_melt_all}
\title{Melt all multiple entries}
\usage{
fhir_melt_all(indexed_data_frame, sep, brackets, rm_indices = TRUE)
}
\arguments{
\item{indexed_data_frame}{A data frame with indexed multiple entries.}
\item{sep}{A string defining the separator that was used when pasting together multiple entries in \code{\link{fhir_crack}}.}
\item{brackets}{A character vector of length 2, defining the brackets used for the indices.}
\item{rm_indices}{Logical of lentgh one. Should indices be removed? Defaults to TRUE as they have no value after comlete melting.}
}
\value{
A data frame where each muliple entry appears in a separate row.
}
\description{
This function divides all multiple entries in an indexed data frame as produced by \code{\link{fhir_crack}}
into separate observations.
}
\details{
Every row containing values that consist of multiple entries will be turned into multiple rows, one for each entry.
Values on other variables will be repeated in all the new rows.
For a more detailed description on how to use this function please see the package vignette.
}
\examples{
#generate example
bundle <- xml2::read_xml(
"<Bundle>
<Patient>
<id value='id1'/>
<address>
<use value='home'/>
<city value='Amsterdam'/>
<type value='physical'/>
<country value='Netherlands'/>
</address>
<birthDate value='1992-02-06'/>
</Patient>
<Patient>
<id value='id2'/>
<address>
<use value='home'/>
<city value='Rome'/>
<type value='physical'/>
<country value='Italy'/>
</address>
<address>
<use value='work'/>
<city value='Stockholm'/>
<type value='postal'/>
<country value='Sweden'/>
</address>
<birthDate value='1980-05-23'/>
</Patient>
<Patient>
<id value='id3.1'/>
<id value='id3.2'/>
<address>
<use value='home'/>
<city value='Berlin'/>
</address>
<address>
<type value='postal'/>
<country value='France'/>
</address>
<address>
<use value='work'/>
<city value='London'/>
<type value='postal'/>
<country value='England'/>
</address>
<birthDate value='1974-12-25'/>
</Patient>
</Bundle>"
)
#crack fhir resources
design <- list(Patients = list(resource = ".//Patient",
style = list(brackets = c("[","]"),
sep = "||")
))
dfs <- fhir_crack(bundles = list(bundle), design = design)
fhir_melt_all(dfs[[1]], brackets = c("[","]"), sep="||")
}