Hello,
I am new to the R community and I need some help!
I am trying to track medications and their dosages longitudinally. I was able to plot a timeline graph using the timevis package, but I wasn't able to make the "group" graph as presented on the webpage.
https://cran.r-project.org/web/packages/timevis/vignettes/overview.html
The dataset is called "med, " which contains some made up data about the name of medications, dose, and start and end dates.
Here is the code that worked to give me medication name or dosage, not both.
library(timevis)
data <- data.frame(
content = med$med_name, #also worked if I use med$dose
start = med$start,
end = med$end
)
timevis(data)
I couldn't figure out how to plot med$med_name as the group names and med$dose as the content. The examples uses c(). I want the code to automatically graph the medications into different groups with the medication name as the group names.
Here is the example code for the "group" graph:
dataGroups <- data.frame(
id = 1:11,
content = c("Open", "Open",
"Open", "Open", "Half price entry",
"Staff meeting", "Open", "Adults only", "Open", "Hot tub closes",
"Siesta"),
start = c("2016-05-01 07:30:00", "2016-05-01 14:00:00",
"2016-05-01 06:00:00", "2016-05-01 14:00:00", "2016-05-01 08:00:00",
"2016-05-01 08:00:00", "2016-05-01 08:30:00", "2016-05-01 14:00:00",
"2016-05-01 16:00:00", "2016-05-01 19:30:00",
"2016-05-01 12:00:00"),
end = c("2016-05-01 12:00:00", "2016-05-01 20:00:00",
"2016-05-01 12:00:00", "2016-05-01 22:00:00", "2016-05-01 10:00:00",
"2016-05-01 08:30:00", "2016-05-01 12:00:00", "2016-05-01 16:00:00",
"2016-05-01 20:00:00", NA,
"2016-05-01 14:00:00"),
group = c(rep("lib", 2), rep("gym", 3), rep("pool", 5), NA),
type = c(rep("range", 9), "point", "background")
)
groups <- data.frame(
id = c("lib", "gym", "pool"),
content = c("Library", "Gym", "Pool")
)
timevis(dataGroups,groups)