I am uploading csv file into a via shiny and trying to draw ggplot from the selected columns.
output$plot = renderPlot(
{
df <- data_set()
gp <- NULL
if (!is.null(df)){
xv <- input$xaxisGrp
yv <- input$yaxisGrp
if (!is.null(xv) & !is.null(yv)){
if (sum(xv %in% names(df))>0){ # supress error when changing files
mdf <- melt(df,id.vars=xv,measure.vars=yv)
gp <- ggplot(data=mdf) +
geom_point(aes_string(x=xv,y="value",color="variable"))+
geom_smooth(method="lm")+
theme(axis.text.x=element_text(angle=45, hjust=1))+
theme_hc() +
scale_colour_hc()+theme(legend.title=element_blank())
}
}
}
return(gp)
}
I can create the chart but when I try to add
+geom_smooth(method="lm")
I am not getting the lm line any ideas what might be happening?
given a data set like this:
dput(df)
structure(list(load = c(1L, 18L, 36L, 72L, 108L, 144L, 216L),
throughput = c(64.9, 995.9, 1652.4, 1853.2, 1828.9, 1775,
1702.2)), .Names = c("load", "throughput"), class = "data.frame", row.names = c(NA,
-7L))
I tried to do:
plot(xy~yv, data=df)
I don't see anything. But to test it, when I do the following, it works. I was not able to find out what the problem is. Again, I am uploading a file to shiny app to plot and create models. Any ideas?
plot(mtcars$mpg~mtcars$cyl) ##this works