smooth_parse {smoothy} | R Documentation |
Transform Data to be Used in smooth_algorithm()
Function
Description
This function transforms the data to obtain the daily treatment.
Usage
smooth_parse(
id,
start_date,
end_date,
drug,
study_from = min(start_date),
study_to = max(end_date)
)
Arguments
id |
Unique identifier of the patient. |
start_date |
Start date of the treatment. |
end_date |
End date of the treatment. |
drug |
Name of the drug used. |
study_from |
A date indicating when the study start. |
study_to |
A date indicating when the study finish. |
Value
A data.frame with the following structure:
- id
Unique identifier of the patient.
- drug
Name of the drug used.
- day
Day of the treatment.
- N
Number of drugs used in the treatment
Examples
library(smoothy)
library(dplyr)
data(drugstreatment)
df <- drugstreatment |>
filter(id == "01f13c15-d9f1-4106-a04f-976c457edd0a")
structured_df <- smooth_parse(
id = df$id,
start_date = df$start_date,
end_date = df$end_date,
drug = df$drug,
study_from = "1970-01-01",
study_to = "1975-01-01"
)
head(structured_df)
[Package smoothy version 1.0.0 Index]