R shiny中的knit2pdf:如何导出renderText

R shiny中的knit2pdf:如何导出renderText,r,shiny,latex,knitr,R,Shiny,Latex,Knitr,我是新来的闪亮,它真的让我头痛这个问题。我制作了一个闪亮的应用程序,您可以上传一个excel,设置一些变量,然后对这些变量进行一些统计测试(首先是回归模型,然后是模型假设)。我需要导出一个pdf文件,其中包含回归模型和统计测试的输出以及测试的结论 我正在使用knit2pdf,这是我的代码: 服务器: testey=reactive({ y=df_sel()[[打印(输入$y)]] 如果(输入$primavar==1){ 概率=adf.检验(y)} 否则{ 如果(输入$primavar==2){

我是新来的闪亮,它真的让我头痛这个问题。我制作了一个闪亮的应用程序,您可以上传一个excel,设置一些变量,然后对这些变量进行一些统计测试(首先是回归模型,然后是模型假设)。我需要导出一个pdf文件,其中包含回归模型和统计测试的输出以及测试的结论

我正在使用knit2pdf,这是我的代码: 服务器:

testey=reactive({
y=df_sel()[[打印(输入$y)]]
如果(输入$primavar==1){
概率=adf.检验(y)}
否则{
如果(输入$primavar==2){
概率=pp试验(y)
}
否则{
概率=kpss.test(y,null=“趋势”)
}}
概率
})
输出$CONSULSIONY 0.05){mensaje=“我们接受零假设,变量是平稳的”}否则{mensaje=“我们拒绝零假设,变量不是平稳的”}
门萨耶}
})
输出$report=downloadHandler(
文件名='myreport.pdf',
内容=函数(文件){
out=knit2pdf('input.Rnw',clean=TRUE)
文件。重命名(输出,文件)#将pdf移动到文件以供下载
},
contentType='application/pdf'
)
input.Rnw

\documentclass{article}

\begin{document}


<<Data>>=


# write.table(datos(),
#                   row.names = FALSE)
@

<<Stationarity>>=
print(testey())
print(Conclusiony())

@


<<Model>>=
print(Reg.model)
print(Reg.fit)
@




\end{document}
\documentclass{article}
\开始{document}
=
#write.table(datos(),
#row.names=FALSE)
@
=
打印(testey())
打印(结论Y())
@
=
打印(注册型号)
打印(注册适合)
@
\结束{document}
反应函数
testey
显示在pdf中,但我不知道如何将
Conclusiony
打印到pdf中,这是一个renderText。renderPlot和RenderRui是如何工作的?有什么建议吗


提前感谢:)

您可以使用无功导体进行结论Y:

Conclusiony <- reactive({
    
    if(input$primavar==1 | input$primavar==2){
      if(testey()$p.value < 0.05){mensaje="We reject the null hypothesis, the variable is stationary"}else{mensaje="We keep the null hypothesis, the variable is not stationary"}
      mensaje}
    else {
      if(testey()$p.value > 0.05){mensaje="We accept the null hypothesis, the variable is stationary"}else{mensaje="We reject the null hypothesis, the  variable is not stationary"}
      mensaje}
  })

output$Conclusiony <- renderText({
  Conclusiony()
})
Conclusiony 0.05){mensaje=“我们接受零假设,变量是平稳的”}否则{mensaje=“我们拒绝零假设,变量不是平稳的”}
门萨耶}
})
输出$Conclusiony
Conclusiony <- reactive({
    
    if(input$primavar==1 | input$primavar==2){
      if(testey()$p.value < 0.05){mensaje="We reject the null hypothesis, the variable is stationary"}else{mensaje="We keep the null hypothesis, the variable is not stationary"}
      mensaje}
    else {
      if(testey()$p.value > 0.05){mensaje="We accept the null hypothesis, the variable is stationary"}else{mensaje="We reject the null hypothesis, the  variable is not stationary"}
      mensaje}
  })

output$Conclusiony <- renderText({
  Conclusiony()
})