I would like to loop through a dataframe and add annotations like
#df.dates is a dataframe with dates in it
for(i in 1:nrow(df.dates))
{
myDyGraph %>%
dyAnnotation(df.dates[i], text = "some text here" )
}
When i run this the chart doesn't update?
Create a chart variable, then add the annotations to it with a loop. So your example would become:
myDyGraph <- dygraph(df)
for(i in 1:nrow(df.dates))
{
myDyGraph <- myDyGraph %>% dyAnnotation(df.dates[i], text = "some text here" )
}
myDyGraph
Similar example with DyLimits here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.