Adjust Rmarkdown's inline chunk output - increase no. of columns displayed? - r

This is a workflow related question. I'm trying out working only (or mostly) in the Rmarkdown source window with the options set to "Chunk output inline". So with R open, there is just one big window -The environment, Console and File windows being minimized.
My question: Is there some option to change the number of columns displayed? I want to increase the numbers of columns visible without scrolling (see screenshot below), and since there is enough space I think it should be possible to display more of them.
Many thanks!

Solution: There is an option. Just add cols.print = 12 (or whatever number you want) to global options.
Also, people might find this 'manual' on markdown useful: https://bookdown.org/yihui/rmarkdown/html-document.html#paged-printing

Related

R bookdown: different output depending on operating system

I render the exact same R bookdown source, but get slightly different results depending on the operating system. This only regards the wrapping of the output width of code chunks when rendering with pandoc to HTML.
If the output is rather large like this
on Windows 10 it adds a horizontal scroll bar, when looking at it on smaller screens.
Running the same code on Ubuntu 20.04 gives me a different result
I checked the output message of bookdown::render_book("index.Rmd", "bookdown::gitbook") and it's the exact same for both operating systems. The pandoc version is the same, too (2.11.4).
Any idea is highly appreaciated.
To inspect options("width") was the right hint from #thothal. I explicitly set the tibble.width but not the width globally.
The lines will break without a horizontal scroll bar, if tibble.width > width. After updating my packages and RStudio I saw the same behavior on both operating systems. Not quiet sure though, what caused the difference in the first place. Maybe something changed for the tibble.width option internally. Or the default width depends on the OS or screen width of the device where it's run (unlikely).
To summarise: The tibble.width has to be equal or smaller than the global width to avoid that ugly line break. It's best to set both explicitly.

How do I set Excel row heights in R using a constant unit (e.g., inches)?

Background: I've written R code to create data summary tables that are exported into Excel templates using openxlsx. The tables vary in size and content with each new dataset, often spanning many pages. The data rows are all the same height, but each page also has a footnote at the bottom, which can vary in height. I have openxlsx code to adjust the height of the footnote row, which must be large enough to fit the text but small enough so the row doesn't get pushed onto the next page. The code is proprietary and I can't post it, but here's an example*:
setRowHeights(
wb,
sheet=excel.tab,
rows=c(rowlist$lastrow.excel),
heights=footnote.height2
)
*All of the inputs other than "wb" are dynamically assigned elsewhere in the program.
Problem: As far as I can tell, openxlsx only allows you to specify row heights in Excel row height units, as opposed to a standard measurement like inches. This seems to result in wildly different row heights (both in inches and in terms of fitting on the same exact page template) depending on the specific computer monitor I'm working on. For example, code that works fine when my laptop is hooked up to my work station will produce giant rows when I'm working on the laptop's monitor. I previously ran into the same issue with the XLConnect package, which makes me think this is a general issue with how R interacts with Excel as opposed to a unique limitation of openxlsx.
I noticed that other openxlsx functions allow you to input the screen's DPI (including vertical and horizontal DPI in some cases) for scaling, which led me to conclude that differences in DPI might account for the scaling discrepancies across screens. Unfortunately, I haven't found a way to import the DPI of a specific screen into R in order to adjust the setRowHeights input to work with that screen.
I've spent countless hours researching and troubleshooting this problem with no luck. Any advice would be greatly appreciated!

GIMP batch editing (Script-fu/Python-fu)

I have about 500 images, I would like edit all of them in batch, I need to resize them all at to 190x120 dimensions, position then slightly higher (say 10 pixels). And export. Also I would like them all to keep their initial names.
Basically I have a frame and I would like to load images (on layer under it) then size them down (above dimensions) move slightly up and export each individual image with frame so that it keeps its name.
What would be a command I could use in GIMP console (script-fu or Python-fu)?
Or what other method could I use to achieve the result without editing each image individually?
Thanks in advance!
i altered one of my own python-fu scripts, and after some testing it seems to do what you want. the interface itself is pretty self-explanatory.
just download the file and install it as a plug-in.
gist link: https://gist.github.com/MCOfficer/bdf6c0c0935d22da38e72cc99fea6375 (archive.md)

Add shortcut to section of long R script?

I have a very long script with more than 5000 lines and I was wondering if I could add shortcuts to sections of the script.
I have separated my script into validation, prediction and figures. I would like to have little shortcut/link at the beginning of the script, so someone that wants to have a look at a part of my script doesn't have to scroll down.
Does anybody knows if such things exist?
In RStudio, if you put four #'s on each side of a comment on its own line, RStudio will mark it as a section that can be navigated to by clicking on it at the bottom of the source code window. It should read 'Top Level' by default.
Example:
#### Calculate standard deviation and moving average ####

QTableWidgetItem multiple lines disappearing

I use a subclassed QTableWidget with QTableWidgetItems in cells to display certain data. In the first row, I have a set of numbers separated by new lines in each cell. My problem is that when I increase font size/decrease cell size, some lines completely disappear, allthough the cell is definitely high enough to contain them.
This usually appears when there is a 2-digit number with some other lines under it and (probably) the font size is greater than the box width can match. I have the elide mode set to none to suppress the "three dots" that appear when this happens.
this->setTextElideMode(Qt::ElideNone);
The first row is resized by
this->resizeRowToContents(0);
this->setRowWidth(0, this->rowWidth(0) + 10);
so that its high enough.
However, the numbers keep on disappearing. Example shown here, note the font size change and missing numbers.
http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug1.png
http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug2.png
I'm starting to be quite desparate about this...any help highly appreciated.
Just to investigate the problem, try:
Make shure that string is correctly created (2,5,10,3) and not (10,3)
Try letters instead of numbers to make shure that they are shown
Try use 3digits nuber alongside with 2digits and see what is happened
May be workaround this by using 01,02 numbers?
Try resizeColumnsToContents() instead of setColumnWidth. If that doesn't work, try calling resizeColumnsToContents() before resizeRowToContents(0).
By the way, is there any reason for calling resizeRowToContents(0) instead of resizeRowsToContents() (note the different name)?

Resources