Ask Your Question
4

How can I create an isolated table in a child Rmd using flexdashboard?

asked 2023-03-03 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-07-18 00:00:00 +0000

qstack gravatar image

You can create an isolated table in a child Rmd using flexdashboard by setting the params attribute and creating a reactive expression that filters the data based on the selected parameters. Here's an example code:

  1. Set the params attribute in the YAML header of your child Rmd file:

    ```


title: "Child Rmd" params: param1: label: "Parameter 1" value: "value1"


```

  1. Add a table to your child Rmd file, and specify the data attribute as a reactive expression that filters the data based on the selected parameters:

    ```{r mytable}
    # assume `df` is a data.frame with columns `col1` and `col2`
    
    filtered_df <- reactive({
     subset(df, col1 == params$param1)
    })
    
    kable(filtered_df())
    

    ```

    This creates a reactive expression filtered_df that returns a subset of the original data frame df based on the selected value of param1.

  2. Knit the flexdashboard containing this child Rmd file. You should see a table that updates based on the selected parameter.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-03-03 11:00:00 +0000

Seen: 4 times

Last updated: Jul 18 '21