glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
613 stars 79 forks source link

Barplot adding in Rmarkdown document #274

Closed shhabnsbwjd closed 1 year ago

shhabnsbwjd commented 1 year ago

Hello

I recently started to use Rmarkdown for generating my official documents. My documents need barplots as well as tables. I am accessing my tables through R code and generating Barplot out of these tables. But when I start to knit my document, it is halted due to barplot in it. When I remove the whole code for barplot and knit, the document is easily generated.

How can I solve this problem because I need these barplot in my document?

I am [[attaching]](Screenshot (2309)) the screenshot of the error I am facing

Thank you

glin commented 1 year ago

Hi,

This doesn't seem to be related to the reactable package (table() is a built-in function in R, and reactable uses reactable()), so I'm going to go ahead and close this. If you are running into an issue with reactable(), post the code and any error messages, and we can reopen this.

For the object of type 'closure' is not subsettable error, I'd recommend double checking that df is actually set to a data frame in the R Markdown document. If it hasn't been set, df will refer to the built-in R function df(), and trying to subset that function will produce a similar error as functions can't be subsetted:

> df
function (x, df1, df2, ncp, log = FALSE) 
{
    if (missing(ncp)) 
        .Call(C_df, x, df1, df2, log)
    else .Call(C_dnf, x, df1, df2, ncp, log)
}
<bytecode: 0x000001d68e95f820>
<environment: namespace:stats>

> df$CONSEQUENCE
Error in df$CONSEQUENCE : object of type 'closure' is not subsettable

# To fix this, make sure df is set to a data frame:
> df <- data.frame(CONSEQUENCE = c(1, 2, 3))
> df$CONSEQUENCE
[1] 1 2 3