I am trying to randomize the page order of a 382-page PDF. I've read that the pdftools package may be the way to go, but I'm not sure if it's able to randomize the PDF order. I was thinking of using pdf_subset to split the existing PDF into two and then using pdf_combine to stick them back together, but I realize that this would just bind them one after the other and not actually mix up the pages. I've also tried something similar in Automator on my Mac (didn't work) but I was curious if there was a way to do this in R.
Thanks in advance!
Related
I am very sorry if this is a stupid question,
I was wondering… let’s say you have an HTML file created from R Markdown containing some graph. More specifically, this HTML document is a flexdashboard. Is it possible to obtain the original dataframe used to create the graph, using only this HTML file?
I don’t know if I managed to explain, but I am worried about the security of the original dataframe.
I suppose the real question is, how does Markdown knit the R chunks? Is it only the outcome of the code that is incorporated in the HTML document... or is it everything? I always thought that because knitr create a .md temporary file that contains the code and its outcomes that meant that it only contained the code and the outcomes and not the original dataframe used to make graphs, stats, tables, etc. But I may be completely wrong and I wish to know the truth.
If anybody has the answer (and maybe some tips in how to secure the flexdashboards), I would be very thankful. I hope I managed to explain my problem in a comprehensible way.
I was interested in generating a course like "swirl" in R. So a course that would interact with the user upon running it. I wanted to start from scratch and I am not sure on how to do this. Is there any specific documentation for this technique or does it have a specific name I could look for?
Maybe learnr with rmarkdown?
With learnr you can create rmarkdown docs that can run code, show results, preserve code and 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 have a PDF with many tables in it, and I'm trying to parse them into a more readable format using R. So far, I've tried two methods:
using pdftools::pdftext() to get the text, then basically using regexes to manually read in the tables (honestly wasn't as bad as it sounds)
using tabulizer::extract_tables(), which somehow magically does all the work for me (it's kinda slow but bearable)
Both methods were surprisingly good, but still had some issues related to messing up the columns/alignment - sometimes columns were combined, sometimes headers were misaligned with the data columns, etc. I'm willing to sort of brute force wrangle the data, but before I try that I just want to see if there are smarter ways to do this.
So, are there better ways to read in tables from PDFs?
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.