Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R文本输入类似于表格格式_R_Input_Text_Shiny - Fatal编程技术网

R文本输入类似于表格格式

R文本输入类似于表格格式,r,input,text,shiny,R,Input,Text,Shiny,我有两个问题: 1) 我想为几个看起来像表格的文本输入字段提供服务。我的解决方案还可以,但由于每个字段的标题,行与行之间的空间太大。如何缩短文本输入字段之间的距离 2) 输出应为data.frame,其中包括来自输入的数据。如何在“Output$contents”中使用输入数据创建data.frame 多谢各位 代码的简短摘录: ui <- fluidPage( # App title ---- titlePanel("Stochastische Cashflows"),

我有两个问题:

1) 我想为几个看起来像表格的文本输入字段提供服务。我的解决方案还可以,但由于每个字段的标题,行与行之间的空间太大。如何缩短文本输入字段之间的距离

2) 输出应为data.frame,其中包括来自输入的数据。如何在“Output$contents”中使用输入数据创建data.frame

多谢各位

代码的简短摘录:

ui <- fluidPage(



# App title ----
  titlePanel("Stochastische Cashflows"),

  # Sidebar layout with input and output definitions ----
  sidebarLayout(


# Sidebar panel for inputs ----
sidebarPanel(

  h4("Psychologisch motivierte Abflüsse aus Einlagen"),
  tags$hr(),

  fluidRow(

    column(6,

           textInput("file1", "Passive Bilanzpostionen eingeben"),
           textInput("file2", "")
    ),

    column(6,

           textInput("file3", "Passive Bilanzpostionen eingeben"),
           textInput("file4", "")
    )
  ),



),

# Main panel for displaying outputs ----
mainPanel(

  # Output: Data file ----
  tableOutput("contents"),


)



 )
)


################################################################################################################

################################################################################################################

server <- function(input, output) {


  output$contents <- renderTable({

   print(9)


  })



################################################################################################################
################################################################################################################

# Create Shiny app ----
shinyApp(ui, server)

###########################################################################################################

ui您可以使用css来减少上边距:

tags$style(type="text/css", "#file2 { margin-top: -20px }")
您可以在创建文本输入后立即放置它

要以数据帧的形式获取内容,最好使用无功导体:

  df <- reactive({
    data.frame(A=c(input$file1, input$file2), B=c(input$file3, input$file4))
  })

  output$contents <- renderTable({
    df()
  })

df您可以使用css设置应用程序的样式
library(shiny)

ui <- fluidPage(
  # App title ----
  titlePanel("Stochastische Cashflows"),
  # Sidebar layout with input and output definitions ----
  sidebarLayout(
    # Sidebar panel for inputs ----
    sidebarPanel(
      h4("Psychologisch motivierte Abflüsse aus Einlagen"),
      tags$hr(),
      fluidRow(
        column(6,
               textInput("file1", "Passive Bilanzpostionen eingeben"),
               textInput("file2", ""),
               tags$style(type="text/css", "#file2 { margin-top: -20px }")
        ),
        column(6,
               textInput("file3", "Passive Bilanzpostionen eingeben"),
               textInput("file4", ""),
               tags$style(type="text/css", "#file4 { margin-top: -20px }")
        )
      )
    ),
    # Main panel for displaying outputs ----
    mainPanel(
      # Output: Data file ----
      tableOutput("contents")
    )
  )
)

# server ----
server <- function(input, output) {

  df <- reactive({
    data.frame(A=c(input$file1, input$file2), B=c(input$file3, input$file4))
  })

  output$contents <- renderTable({
    df()
  })

}

# Create Shiny app ----
shinyApp(ui, server)