显示数据集并卸载先前的操作时出现问题 [英] Issues while displaying the dataset and unloading previous operations

查看:69
本文介绍了显示数据集并卸载先前的操作时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在这里几乎没有问题.这是我add并加载csv文件的代码.但是有一些问题,我也不需要什么.请求任何人帮助我

I have few issues in the app here. This is the code wherein I add and Load csv files. But There are some issues and also I require few things. Request anyone to help me

问题: 1)我无法加载第二个文件.不知道为什么吗? 2)我也添加了删除按钮,因此,一旦单击Remove按钮,就应该卸载相应的文件. 3)我们可以在加载新文件的同时创建另一个输出,它应该显示前15行head(df, n = 6)

Issues : 1) I am not able to load second file. Not sure why? 2) I have added the remove button as well, so that Once Remove button is clicked the respective file should be unloaded. 3) Can we create another output where as and when new file is load, it should display first 15 rows head(df, n = 6)

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(rhandsontable)
```

Column {data-width=650}
-----------------------------------------------------------------------

```{r}
actionButton("add", "Add UI",width = 100)

observeEvent(input$add, {
    insertUI(
      selector = "#add",
      where = "afterEnd",
      ui = fileInput("file1", "Choose CSV File", accept = c( "text/csv", "text/comma-separated-values,text/plain", ".csv"))
      ,multiple = FALSE
    )
    insertUI(
      selector = "#add",
      where = "afterEnd",
      ui = actionButton("V","Remove",width = 100))
  })
observeEvent(input$V,{
     removeUI(selector = '#file1')
   }) 
```

推荐答案

这里有另一种设计,希望对您有所帮助

Here a different design I hope it helps

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(rhandsontable)
```

Column {data-width=650}
-----------------------------------------------------------------------

```{r}
actionButton("add", "Add UI",width = 100)
observeEvent(input$add, {
  remove_id <- paste0("remove_", input$add)
  insertUI(
    selector = "#add",
    where = "afterEnd",
    ui = tags$div(fileInput(paste0("file",input$add), paste0("Choose CSV File", input$add), accept = c( "text/csv", "text/comma-separated-values,text/plain", ".csv")),
                  actionButton(remove_id, paste0("Remove",input$add), width = 100), id=remove_id), multiple = FALSE)

observeEvent(input[[remove_id]],{
  removeUI(selector = paste0("#",remove_id), immediate = TRUE, multiple = TRUE)
})
})

```

这篇关于显示数据集并卸载先前的操作时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆