Hello everyone!
I apologize for bothering you but I am stuck with a ggplot graph that is providing poor rendering for Shiny.
I have been reading up online on how to display the equation of a regression lines onto a ggplot2 graph. However, I have been unable to find something that would fit my needs. I am working with a team of data analysts and they want me to design a simplistic system that allows them to choose different types of regression equations. (ie : lm, glm, gam, loess, rlm ) When they generate these plots they want to have the equation for the plot displayed with the graph.
I found the following 2 links with gave me a head start on what I needed to do:
However, I have two main problems. First, I am attempting to use this library from github: ggplot_smooth_func.R
The issue with this is that the graph displayed is not generating properly when using Shiny.
Here is some example code:
library(shiny)
library(ggplot2)
shinyApp(
ui = fluidPage( plotOutput('plot1')),
server = function(input, output) {
output$plot1 <- renderPlot({
ggplot(data = mtcars, aes(x = cyl, y = vs, label=carb)) +
stat_smooth_func(geom="text",method="lm",hjust=0,parse=TRUE) +
geom_smooth(method="lm",se=FALSE) +
geom_point()
})
})
If I generate the plot within RStudio the equation renders just fine. :/
In addition to this problem, I need to be able to display multiple lines of equations. The users I am working with will be using multiple sets of data and, because of this, they will need to have each line's regression equation. Is it possible to do this? I realize this is a shiny based forum, I am just asking in case someone knows already.
Also, would the regression equations for the lm, glm, gam, loess, rlm be the same ? I am assuming they are not but I am only finding solutions dealing with the lm equation.
Thanks so much for your help and time!
Amber James