I am trying to create a flexdashboard that includes a Data Table along with Crosstalk Filters. My data includes similar data that I would like to aggregate to find the means of certain categories according to filter criteria. Basically, the table will be aggregated data.
It is my understanding that Crosstalk wasn't meant to aggregate data, but does anyone know a way around this? I'm willing to look at any way possible.
Thank you!
You are looking for the summaryWidget package
link to github page
Related
I am using react-table-6, I am trying to group my table data with pivot grouping. I have got to work to some extent, but my requirement is different. I have given my requirement in the GitHub link.
Can you help me in grouping the data as per the requirement. Thanks in advance.
(I'm new here so hopefully I am asking this in the correct way).
I am using Rmarkdown to create a summary table, and am using dfSummary within the summarytools package. I have created the table using this code:
Here is a picture of my current R-markdown:
I would like the order of the results for character variables to be listed in order of descending frequency, not alphabetical. I have read many pages summarize the package but cannot find an answer. Any help would be great!
There is no option to do that in summarytools directly. (You can open an issue on the GitHub project page for a feature request.) The ordering by frequency is done only when there are more distinct values than allowed by max.distinct.values.
The easiest way to proceed would be to recode your character variable with forcats::fct_infreq:
library(forcats)
df$var_f <- fct_infreq(df$var)
The order of factor levels will be preserved in the the results.
I’ve been looking for an hour, but everything I can find about how to make a nice looking table out of a data frame mentions that it’s for rmarkdown, html, or latex.
Is it not possible to make a nice looking table in base r?
plot(x, y) makes a graph.
Is there no function like: printTable(df)?
Broadly speaking over what you can get from a normal print in base::print there is not much else you can do. You could try to twist plot function to plot values from selected cells in a data frame but that would be very onerous to develop and impractical in the light of currently available and maintained solutions. There is a number of packages that let you achieve what you need. For instance you can try formattable by renkun-ken.
Example
For a simple example you can try formattable::formattable(mtcars[1:10,])
Creating Images
For a solution creating images from tables, have a look at this discussion. As discussed, in the linked answer if you insist on generating a static image you can use grid.table function offered via gridExtra: tbl <- grid.table(mtcars[1:5,]).
You may be interested in the flextable package that is very easy to use with multiple options to create nice tables.
You can also have multiple word, pdf, or html output types.
I invite you to check the manual : https://cran.r-project.org/web/packages/flextable/vignettes/overview.html
I would be grateful if anyone could tell me how to create pivot table in R like python pandas with selected aggregation function and more then one level in column.
I would like to receive in R something like this in python:
Iris.pivot_table(index='Sepal.Length',columns=['Sepal.Width','Species'],values='Petal.Length',aggfunc=sum)
I know there is pivotabler package, but default rendering to html method is to slow for a bit larger tables.
I also have found ftable function from stats package but its only for contingency tables, in which I can`t specify my own aggregation function.
Thank you.
Recently I was exposed to the grid.table function in the package gridExtra in R. I am simply looking to make my dataframes look "better" than simply printing them to the console.
The default settings work pretty well, but now I am getting greedy. I am asking for help because I am not sure if the following two formatting settings are possible. I read the documentation but am still not sure if this can happen...
Conditionally format/highlight rows and columns if they meet a certain criteria. My thinking was that I could highlight a certain row to make it stand out from the rest of the table.
Is it possible to left alight the first column in the table and center align everything else?
In short, I really like how easy it is to format a dataframe as a table, but now I am hoping I can do a few extra formatting techniques to get the tables to where I need them to be.
Having just emailed Baptiste the author of gridExtra, that functionality is not currently available.
However, he says that once the gtable package is officially released he is planning to make an update to grid.table which should make it easier to customise the output. But also says not to "hold your breath"...He also however suggested to feel free to use the source code and adapt it.
But I too have been looking for ways to highlight rows in tables and have used the package dprint to do so. Hope that helps.