Q:

R Shiny textInput like table format

I have two questions:
1) I want to serve several text Input fields that look like a table. My solution is ok, but there is too much space between the lines due to the title for each field required. How can I shorten the distance between the text Input fields?
2) The Output shall be a data.frame which includes data from the Input. How can I create a data.frame out of Input data in "Output$contents"?
Thank you.
Shortened extract of the code:
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)

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

A:

You can use a css to reduce the top margin:
tags$style(type="text/css", "#file2 { margin-top: -20px }")

You can put it just after you create the text input.
To get the contents as a dataframe, a reactive conductor is nice:
  df <- reactive({
    data.frame(A=c(input$file1, input$file2), B=c(input$file3, input$file4))
  })

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

Complete code:
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)

