Make flowers
a column of the data.frame
you're plotting from, instead of a separate object.
pairs3$flowers <- input$vector
Then try your plotting code.
Question
Trying to do a simple thing and coming up against unexpected trouble. I am putting together an RShiny app and would like to label the points in my ggplot graph.
My code is below. I do not understand why I cannot pass in the variable flowers to get the point labels in the chart. For comparison's sake, the commented lines work completely fine when I remove all attempts at point labels (which suggests it's not a problem with variable passthroughs from other functions, etc.)
In addition, directly putting in rownames() into the aes also does not work.
Thanks for your help.
output$graph=renderPlot({
pairs2=pctchg()
pairs3=as.data.frame(pairs2)
rownames(pairs3)=input$vector[]
flowers=rownames(pairs3)
#basegraph=ggplot(pairs3,aes(x,y))
basegraph=ggplot(pairs3,aes(x,y,label=flowers))
globalvars=basegraph + geom_point() + geom_smooth(method = 'lm') + geom_text(aes(label=flowers))
#globalvars=ggplot(pairs3,aes(x,y)) + geom_point() + geom_smooth(method = 'lm')
print(globalvars) })
Solution
Make flowers
a column of the data.frame
you're plotting from, instead of a separate object.
pairs3$flowers <- input$vector
Then try your plotting code.