我有调查数据。我想用Shiny与合作者分享我的单变量和双变量分析的结果。在调查中有数字和因子变量。根据观看Shiny应用程序的人是否对单变量/双变量摘要感兴趣,并且根据他们想要汇总的变量类型,我希望显示不同的输出。
具体地,
i)如果是单变量和数字,则显示:
length() - sum(is.na())
hist()
summary()
ii)如果是单变量和因子,则显示:
barplot()
table()
prop.table()
iii)如果是双变量和数字*数字,则显示:
plot(x,y)
summary(x)
summary(y)
cor(x,y,method="spearman")
iv)如果是双变量和因子*因子,则显示:
table(x,y)
prop.table(x,y)
chisq.test(x,y)
v)如果是双变量和(因子*数字或数字*因子),则显示:
by(numeric, factor, summary)
kruskal.test(numeric ~ factor)
目前,我有代码为所有5个步骤生成所需的输出作为单独的应用程序。我想把它们组合成一个闪亮的应用程序。我在概念上苦苦思索如何将mainPanel()
显示设置为对将根据用户在sidebarPanel()
UI上做出的选择的函数接收的不同输出做出反应。
具体地,
mainPanel()
用户界面标题以反映不同的输出verbatimTextOutput()
但我不知道如何继续我希望的多个/类型的输出显示如上文(i-iv)中所述。例如文本,表格,图表。以下是我的ui.R文件代码:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Shiny Example"),
sidebarPanel(
wellPanel(
selectInput(inputId = "variable1",label = "Select First Variable:",
choices = c("Binary Variable 1" = "binary1",
"Binary Variable 2" = "binary2",
"Continuous Variable 1" = "cont1",
"Continuous Variable 2" = "cont2"),
selected = "Binary Variable 1"
)
),
wellPanel(
checkboxInput("bivariate", "Proceed to Bivariate Analysis", FALSE),
conditionalPanel(
condition="input.bivariate==true",
selectInput(inputId = "variable2",
label = "Select Second Variable:",
choices = c("Binary Variable 1" = "binary1",
"Binary Variable 2" = "binary2",
"Continuous Variable 1" = "cont1",
"Continuous Variable 2" = "cont2"),
selected = "Binary Variable 2"
)
)
)
),
mainPanel(
h5("Output"),
verbatimTextOutput("out")
)
))
下面是我的模拟数据和我的server.R文件:
binary1 <- rbinom(100,1,0.5)
binary2 <- rbinom(100,1,0.5)
cont1 <- rnorm(100)
cont2 <- rnorm(100)
dat <- as.data.frame(cbind(binary1, binary2, cont1, cont2))
dat$binary1 <- as.factor(dat$binary1)
dat$binary2 <- as.factor(dat$binary2)
dat$cont1 <- as.numeric(dat$cont1)
dat$cont2 <- as.numeric(dat$cont2)
library(shiny)
library(rCharts)
shinyServer(function(input, output) {
inputVar1 <- reactive({
parse(text=sub(" ","",paste("dat$", input$variable1)))
})
inputVar2 <- reactive({
parse(text=sub(" ","",paste("dat$", input$variable2)))
})
output$out <- renderPrint({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
table(eval(inputVar1()))
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
summary(eval(inputVar1()))
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
table(eval(inputVar1()), eval(inputVar2()))
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
cor(eval(inputVar1()), eval(inputVar2()))
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
by(eval(inputVar2()), eval(inputVar1()), summary)
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
by(eval(inputVar1()), eval(inputVar2()), summary)
}
}
}
}
}
}
})
})
非常感谢您提供的任何帮助。甚至简单地展示如何调整代码以在给定变量选择的情况下呈现两个期望的输出。以及如何调整标题以反映命名的输出部分。
提前致谢... Chris
答案 0 :(得分:10)
即使问题很久以前,我想也许这种方法更好,不需要服务器端的其他代码。
mainPanel(
wellPanel(
conditionalPanel(
condition = "input.myInput == 'value'",
..... Your UI for this case ...........
),
conditionalPanel(
condition = "input.myInput == 'value2'",
..... Your UI for this case ...........
)
)
)
答案 1 :(得分:5)
我修改了您的Shiny代码(见下文),以便它能够满足您的需求。根据Uni vs Bivariate分析的选择,它会切换标签并显示相关结果。
从广义上讲,以下是我必须在代码中更改以获得所需行为的内容:
tabPanel
以便输出可以分段。observe
被动,以便可以在那里监视您已经进行的嵌套if-else。h4
添加到相应的tabPanel
s 下面附有一个完整的代码。以此为出发点,从那里开始。
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Conditional Tab Switch Example"),
sidebarPanel(
wellPanel(
selectInput(inputId = "variable1",label = "Select First Variable:",
choices = c("Binary Variable 1 (Factor)" = "binary1",
"Binary Variable 2 (Factor)" = "binary2",
"Continuous Variable 1 (Numeric)" = "cont1",
"Continuous Variable 2 (Numeric)" = "cont2"),
selected = "Binary Variable 1 (Factor)"
)
),
wellPanel(
checkboxInput("bivariate", "Proceed to Bivariate Analysis", FALSE),
conditionalPanel(
condition="input.bivariate==true",
selectInput(inputId = "variable2",
label = "Select Second Variable:",
choices = c("Binary Variable 1 (Factor)" = "binary1",
"Binary Variable 2 (Factor)" = "binary2",
"Continuous Variable 1 (Numeric)" = "cont1",
"Continuous Variable 2 (Numeric)" = "cont2"),
selected = "Binary Variable 2 (Factor)"
)
)
)
),
mainPanel(
h5("Output"),
tabsetPanel(id ="analysisTabs",
tabPanel(title = "Univariate Numeric", value="panel_uni_numeric",
h4(" Univariate Numeric"),
verbatimTextOutput("uni_numeric")),
tabPanel(title = "Univariate Factor", value="panel_uni_factor",
h4(" Univariate Factor"),
verbatimTextOutput("uni_factor")),
tabPanel(title = "Bivariate Numeric-Numeric", value="panel_bi_nn",
h4(" Bivariate Numeric Numeric"),
verbatimTextOutput("bi_numeric1_numeric2")),
tabPanel(title = "Bivariate Factor-Factor", value="panel_bi_ff",
h4(" Bivariate Factor Factor"),
verbatimTextOutput("bi_factor1_factor2")),
tabPanel(title = "Bivariate Numeric-Factor", value="panel_bi_nf",
h4(" Bivariate Numeric Factor"),
verbatimTextOutput("bi_numeric1_factor2")),
tabPanel(title = "Bivariate Factor-Numeric", value="panel_bi_fn",
h4(" Bivariate Factor Numeric"),
verbatimTextOutput("bi_factor1_numeric2"))
)
)
))
binary1 <- rbinom(100,1,0.5)
binary2 <- rbinom(100,1,0.5)
cont1 <- rnorm(100)
cont2 <- rnorm(100)
dat <- as.data.frame(cbind(binary1, binary2, cont1, cont2))
dat$binary1 <- as.factor(dat$binary1)
dat$binary2 <- as.factor(dat$binary2)
dat$cont1 <- as.numeric(dat$cont1)
dat$cont2 <- as.numeric(dat$cont2)
library(shiny)
#library(rCharts)
shinyServer(function(input, output, session) {
inputVar1 <- reactive({
parse(text=sub(" ","",paste("dat$", input$variable1)))
})
inputVar2 <- reactive({
parse(text=sub(" ","",paste("dat$", input$variable2)))
})
output$uni_factor = renderText({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
table(eval(inputVar1()))
}
})
output$uni_numeric = renderPrint({
if( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
summary(eval(inputVar1()))
}
})
output$bi_factor1_factor2 = renderText({
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
table(eval(inputVar1()), eval(inputVar2()))
}
})
output$bi_numeric1_numeric2 = renderPrint({
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
cor(eval(inputVar1()), eval(inputVar2()))
}
})
output$bi_numeric1_factor2 = renderPrint({
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
by(eval(inputVar2()), eval(inputVar1()), summary)
}
})
output$bi_factor1_numeric2 = renderPrint({
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
by(eval(inputVar1()), eval(inputVar2()), summary)
}
})
observe({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
print("uni f")
updateTabsetPanel(session, inputId="analysisTabs", selected="panel_uni_factor")
}
else if( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
print("uni n")
updateTabsetPanel(session, inputId="analysisTabs", selected="panel_uni_numeric")
}
else if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
print("bi f f")
updateTabsetPanel(session, inputId="analysisTabs", selected="panel_bi_ff")
}
else if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
print("bi n n")
updateTabsetPanel(session, inputId="analysisTabs", selected="panel_bi_nn")
}
else if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
print("bi f n")
updateTabsetPanel(session, inputId="analysisTabs", selected="panel_bi_fn")
}
else if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
print("bi n f")
updateTabsetPanel(session, inputId="analysisTabs", selected="panel_bi_nf")
}
})#end observe
})
<强>更新强>
根据评论,我更新了server.R,只显示了满足渲染条件的结果。具体来说,请注意output$uni_factor = renderText({
类型语句后面的每个if语句。
仍然可以单击选项卡,但它们不会显示任何结果。 (Shiny小组讨论过完全隐藏标签,但据我所知,它尚未明确实施。)
答案 2 :(得分:1)
我已经如上所述继续解决这个问题。我在server.R文件中嵌入了一系列嵌套的if else语句,以根据所选输入有条件地生成标题。我使用ui.R文件中的textOutput()
函数在mainPanel
UI中显示这些标题。这很好用,但不确定它是否是最好的方法。很想听听这种方法的想法吗?
对于条件输出......取决于变量和分析的选择(单变量或双变量)我想生成最多5个输出。所以,我再次使用一系列嵌套的if else语句来生成这些输出。然后显示在ui.R文件中。我现在的问题是那些不需要5个输出(最大可能)的变量组合和分析。对于他们,我返回NULL
对象。我的问题是Shiny不会为这些输出打印空白空白。相当闪亮的返回灰色框和单词&#34; NULL&#34;。它看起来很丑陋,我非常感谢有关如何将这个输出简单地变成空白的任何反馈。
我的新ui.R代码如下:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Shiny Example"),
sidebarPanel(
wellPanel(
selectInput( inputId = "variable1",label = "Select First Variable:",
choices = c("Binary Variable 1" = "binary1",
"Binary Variable 2" = "binary2",
"Continuous Variable 1" = "cont1",
"Continuous Variable 2" = "cont2"),
selected = "Binary Variable 1"
)
),
wellPanel(
checkboxInput("bivariate", "Proceed to Bivariate Analysis", FALSE),
conditionalPanel(
condition="input.bivariate==true",
selectInput(inputId = "variable2",
label = "Select Second Variable:",
choices = c("Binary Variable 1" = "binary1",
"Binary Variable 2" = "binary2",
"Continuous Variable 1" = "cont1",
"Continuous Variable 2" = "cont2"),
selected = "Binary Variable 2"
)
)
)
),
mainPanel(
h5("Item Response Rate"),
verbatimTextOutput("nitem"),
h5(textOutput("caption2")),
verbatimTextOutput("out2"),
h5(textOutput("caption3")),
verbatimTextOutput("out3"),
h5(textOutput("caption4")),
verbatimTextOutput("out4"),
h5(textOutput("caption5")),
plotOutput("out5")
)
))
以下是我的server.R文件的代码:
binary1 <- rbinom(100,1,0.5)
binary2 <- rbinom(100,1,0.5)
cont1 <- rnorm(100)
cont2 <- rnorm(100)
dat <- as.data.frame(cbind(binary1, binary2, cont1, cont2))
dat$binary1 <- as.factor(dat$binary1)
dat$binary2 <- as.factor(dat$binary2)
dat$cont1 <- as.numeric(dat$cont1)
dat$cont2 <- as.numeric(dat$cont2)
library(shiny)
shinyServer(function(input, output) {
inputVar1 <- reactive({
parse(text=sub(" ","",paste("dat$", input$variable1)))
})
inputVar2 <- reactive({
parse(text=sub(" ","",paste("dat$", input$variable2)))
})
output$nitem <- renderPrint({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
n <- sum(table(eval(inputVar1())))
p <- n/100
out <- cat(paste(n,gsub(" ","",paste("(",round(as.numeric(p)*100,2),"%",")"))),"\n")
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
n <- sum(table(eval(inputVar1())))
p <- n/100
out <- cat(paste(n,gsub(" ","",paste("(",round(as.numeric(p)*100,2),"%",")"))),"\n")
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
n <- sum(table(eval(inputVar1()),eval(inputVar2())))
p <- n/100
out <- cat(paste(n,gsub(" ","",paste("(",round(as.numeric(p)*100,2),"%",")"))),"\n")
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
n <- sum(table(eval(inputVar1()),eval(inputVar2())))
p <- n/100
out <- cat(paste(n,gsub(" ","",paste("(",round(as.numeric(p)*100,2),"%",")"))),"\n")
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
n <- sum(table(eval(inputVar1()),eval(inputVar2())))
p <- n/100
out <- cat(paste(n,gsub(" ","",paste("(",round(as.numeric(p)*100,2),"%",")"))),"\n")
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
n <- sum(table(eval(inputVar1()),eval(inputVar2())))
p <- n/100
out <- cat(paste(n,gsub(" ","",paste("(",round(as.numeric(p)*100,2),"%",")"))),"\n")
}
}
}
}
}
}
})
output$caption2 <- renderText({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
caption2 <- "Univariate Table"
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
caption2 <- "Univariate Summary"
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
captions2 <- "Bivariate Table"
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption2 <- "Numeric Summary First Variable"
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption2 <- "Numeric Summary By Factor"
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
caption2 <- "Numeric Summary By Factor"
}
}
}
}
}
}
})
output$out2 <- renderPrint({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
table(eval(inputVar1()))
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
summary(eval(inputVar1()))
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
table(eval(inputVar1()), eval(inputVar2()))
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
summary(eval(inputVar1()))
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
by(eval(inputVar2()), eval(inputVar1()), summary)
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
by(eval(inputVar1()), eval(inputVar2()), summary)
}
}
}
}
}
}
})
output$caption3 <- renderText({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
caption3 <- "Univariate Table of Proportions"
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
caption3 <- ""
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
captions3 <- "Bivariate Table of Row Proportions"
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption3 <- "Numeric Summary Second Variable"
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption3 <- "Kruskal Wallis Test"
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
caption3 <- "Kruskal Wallis Test"
}
}
}
}
}
}
})
output$out3 <- renderPrint({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
prop.table(table(eval(inputVar1())))
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
NULL
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
prop.table(table(eval(inputVar1()), eval(inputVar2())), margin=1)
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
summary(eval(inputVar2()))
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
kruskal.test(eval(inputVar2()) ~ eval(inputVar1()))
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
kruskal.test(eval(inputVar1()) ~ eval(inputVar2()))
}
}
}
}
}
}
})
output$caption4 <- renderText({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
caption4 <- ""
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
caption4 <- ""
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
captions4 <- "Pearsons Chi-Squared Test"
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption4 <- "Spearmans Correlation Coefficient"
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption4 <- ""
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
caption4 <- ""
}
}
}
}
}
}
})
output$out4 <- renderPrint({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
NULL
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
NULL
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
chisq.test(table(eval(inputVar1()), eval(inputVar2())))
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
cor(eval(inputVar1()), eval(inputVar2()), method="spearman", use="pairwise.complete.obs")
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
NULL
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
NULL
}
}
}
}
}
}
})
output$caption5 <- renderText({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
caption5 <- "Univariate Barplot"
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
caption5 <- "Univariate Histogram"
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
captions5 <- "Bivariate Barplot"
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption5 <- "Bivariate Scatter Graph"
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
caption5 <- "Bivariate Boxplot"
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
caption5 <- "Bivariate Boxplot"
}
}
}
}
}
}
})
output$out5 <- renderPlot({
if ( (input$bivariate==FALSE) & (is.factor(eval(inputVar1()))==TRUE) ) {
barplot(table(eval(inputVar1())))
} else {
if ( (input$bivariate==FALSE) & (is.numeric(eval(inputVar1()))==TRUE) ) {
hist(eval(inputVar1()),main="")
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
barplot(table(eval(inputVar1()), eval(inputVar2())), beside=TRUE)
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
plot(eval(inputVar1()), eval(inputVar2()), main="")
} else {
if ( (input$bivariate==TRUE) & (is.factor(eval(inputVar1()))==TRUE) & (is.numeric(eval(inputVar2()))==TRUE) ) {
boxplot(eval(inputVar2()) ~ eval(inputVar1()))
} else {
if ( (input$bivariate==TRUE) & (is.numeric(eval(inputVar1()))==TRUE) & (is.factor(eval(inputVar2()))==TRUE) ) {
boxplot(eval(inputVar1()) ~ eval(inputVar2()))
}
}
}
}
}
}
})
})
如前所述,我目前的问题是打印&#34; NULL&#34;输出。如果有人对如何抑制此输出有任何建议,我将非常感谢您的反馈。此外,我欢迎对提议的解决方案的想法,与其他可行的解决方案相比。