Laiyang9319 / Coding-in-R-for-Policy-Analytics

MIT License
0 stars 0 forks source link

Error in renderPlot({ : could not find function "renderPlot" #2

Open mvogt404 opened 4 months ago

mvogt404 commented 4 months ago

I am starting Lab 4 and installed shiny and flexdashboard but am still getting the error

'''{r} Error in renderPlot({ : could not find function "renderPlot" '''

I have omitted more of the plot code, but included the first section below. I'm not sure how to proceed.

library( dplyr )
library( Lahman )
library( pander )
data( Teams )

ave.so <- Teams$SO / Teams$G  # average strike-outs per game each season 
year <- Teams$yearID

Teams$ave.so <- Teams$SO / Teams$G  # add back to data frame so you can subset

```{r}

renderPlot({

plot.new()
plot.window( 
  xlim=c(1900,2025), 
  ylim=c( ave.so.min, ave.so.max ) )
points( year, ave.so, 
        col=adjustcolor("lightgray",alpha=0.75 ), 
        pch=20, cex=1)
points( league.year, league.ave, 
        type="o",lwd=3, 
        col=adjustcolor("dodgerblue4", alpha=0.67),
        cex=.5,pch=19 )
points( 1924, 2.7, 
        col=adjustcolor("black",alpha=0.75 ), 
        pch=21, cex=1.5)
points( 2012, 7.5, 
        col=adjustcolor("black",alpha=0.75 ), 
        pch=21, cex=1.5)

})
Laiyang9319 commented 4 months ago

For running Shiny, you are not suppose to run code chunks one by one but to run the entire document at once by clicking the "Run Document" option at the top.