我试图通过添加一个新行然后使用闪亮的输入和输出渲染最新更新的表来连续填充数据框 . 用户在文本字段中键入“推荐”,并且每次单击操作按钮时都需要将其添加到数据框中 . 用户应该能够根据需要添加任意数量的行 . 这是我的代码:
server.R
# here I am using observe and isolate to ensure the action button only applies to the textfield in question
values
observe({
if(input$actionButton > 0) {
values$textInput
}
})
# here is the output to render the table. Note that there is a function called "addRec" which brings in the current data frame with existing recommendations and the most recently typed recommendation from the text input
output$table
p
p
})
我的ui.R像往常一样显示了这张 table
htmlOutput("table")
这是我用于向数据框添加新行的函数 . 它接收当前存在的数据帧,使用新的textinput和其他一些值添加一行,使用绑定创建新的数据帧,然后返回新形成的帧 .
addRec
newRecommendation
lFinal
newFrame
return(newFrame)
}
你可以在我的server.R文件中看到输出$ table递归地将最新的表添加到函数中 . 但我得到的只是返回没有新行的同一个表 . 当用户在文本字段中输入推荐时,它只是实时更新最后一行 . 每次新推荐时我都需要输出一个新的数据帧 .