我是一个没有经验的程序员,对Shiny来说是全新的。为了透明,我这样做是作为学校作业的一部分,但也想真正学习如何使用ShinyApps和数据可视化工具。任何帮助将不胜感激。
Server.R - 对于这个,我在开始渲染图时开始收到错误。当我查看时间序列图的其他代码示例时,输出后面会有一个字符串($)。我不确定这是否适用于我的情节。我还认为' plot_impact_by_year'存在问题。同样,我不知道我是否应该引用其他内容或根本不引用任何内容。
library(shiny)
library(ggplot2)
library(rCharts)
# Load data
dt <- read.csv("NBAdata.csv", header=TRUE)
# Shiny server
shinyServer(function(input, output, session) {
})
# Prepare datasets
# Prepare for time series
dt.agg.year <- reactive({
aggregate_by_year(dt, input$range[1], input$range[2])
})
# Render Plots
# 3-Pointers by Year
output <- renderChart({
plot_impact_by_year(
dt = dt.agg.year() %>% select(Year, 3PM, 3PA),
yAxisLabel = "3-Pointers Per Game",
desc = TRUE
)
})
# Fouls versus Pace and Points by Year
output <- renderChart({
plot_impact_by_year(
dt = dt.agg.year() %>% select(Year, PF, Pace, Pts),
yAxisLabel = "Per Game Statistics",
desc = TRUE
)
})
ui.R - 当我单独运行代码时,当我输入最后一个封闭的括号时,我收到以下错误:
addResourcePath(LIB $ name,LIB $ url)出错: 调用带有无效前缀的addResourcePath;请参阅文档
library(shiny)
library(rCharts)
# Load the dataset
dt <- read.csv("NBAdata.csv", header=TRUE)
shinyUI(
navbarPage("3-Pointers and Pace of Play in the NBA",
tabPanel("Plot",
sidebarPanel(
sliderInput("Year", "Year:",
min = 1979, max = 2015, value = c(1995, 2015),
),
mainPanel(
tabsetPanel(
# Time series data
tabPanel(p(icon("line-chart"), "By year"),
h4('Number of 3-pointers by year', align = "center"),
showOutput("3PM", "3PA")),
tabPanel(p(icon("line-chart"), "By year"),
h4('Fouls versus Pace and Points by year', align = "center"),
showOutput("PF", "Pace", "Pts")),
)
)
)
)
)
)