Chunk does not display executed code result/plot in R - r

Chunk output inline setting not working.
I started R for my daily work, and when ran a code (simply display a subset of a data frame) nothing is shown, neither inline nor on the console or viewer. I have set absolutely nothing differently, didn't even touch the settings. It says "Chunk output inline" anyway.
It was working normally for a year, and now from a day to the other, this happens. If I execute the subsetting in the console, then it displays the subset in the console. But if I execute in the chunk, no displaying anywhere.
Thanks in advance

Related

How to increase the amount of lines you can read in R's view()

In an RMarkdown file, you can see the below sample text in red. It prints in the console and the RStudio Notebook Output (using view()) up to 10,000 lines after running my code.
However, the total text is 20,000 lines long. I can't find help online which indicates how to increase the number of lines you can view in R and I need to access all of it. Can anyone help? I want to view all of the text basically.
Note that my code took hours to run, RStudio crashed when the code finished executing, and the information I need is saved in red. Hence, I can't re-run the code without the same problem occurring.

Jupyter Notebook cell stopped working as such

There is the first cell that is supposed to execute code as the rest, but somehow it's not even working at all.
The next cells are working properly, but this forst one doesn't recognize my input.
In the pictures provided you can see that the next cell recognizes my input as code and highlights the proper words in color. When I first opened the notebook it was alright, but it just stopped working for this first cell.
I have tried to close and reopen, interrupt kernel and everything in my hands.
Thank you very much for your time.
Cell was not stuck on an infinite loop. Somehow Jupyter Notebook stopped recognizing it as a code cell. Therefore you have to manually srt it back to code cell. See image.

Can I check for duplicate labels before knitting the whole document using knitr?

I have a report made of several Rmd files (several layers of child documents).
I always end up doing a copy paste and forget to change the chunk names, it's annoying because the report takes minutes to knit before the error pops up.
I use the chunk names to debug, and in the end they're often the ones that make my code crash, there has to be a better way.
How can I check programmatically that everything's clear before attempting to knit ?
Apparently there exists this option that allows you to keep duplicate chunk labels and still knit:
options(knitr.duplicate.label = 'allow')

Redirect Output to Message r

Is it possible to capture output that is printed by a function and instead output it via message? I am running a report using knitr that deals with very large tables (millions of rows) and I have message statements in the code so I can have an idea of where I am. This works fine as I simply set the global chunk option to message = F and I can see the message in the console and it does not show up in the final pdf. However, I use fread to read the data from a file, and the showProgress option does not print a message! Setting the chunk option to results='hide' prevents the progress from being printed to the final document, but it also prevents me from seeing it at all, so that is unhelpful. Any help would be appreciated, thanks!

Edit text/comments of rmarkdown and knitr reports without rerunning code

I love knitr & rmarkdown, but I often find myself in situations where I have a lengthy report that takes some nontrivial amount of time to run. After it's generated, I notice my inevitable typos in text. However, re-knitting everything to just fix a couple typos (just in text, not code) takes a long time and seems avoidable. I was about to start taking a hack at developing my own solution to this, but I'm thinking it's the kind of thing that could already have a mature solution which would likely be more robust than the one I'd build.
I'm wondering if there is solution out there within knitr or third party that would allow me to edit just the text of my reports without rerunning code, generating plots and outputs etc. I know, I can simply edit the generated html text, but then those changes must be replicated in the R/Rmd code that generated it, or they get out of sync. I'm envisioning a function like this:
argument 1: the R/Rmd script with text edits (no code changes)... perhaps a warning is generated when code chunks change
argument 2: the html output file from the last time the R script in argument was knitted without the text edits.
return: the html report (argument 2) updated with the comments in the R/Rmd script (argument 1).
I use the cache option sometimes for large datasets. I toggle eval and echo on and off when developing if I'm just working on the text of my report. However, I'm looking for a function that would take care of all this for me, so one doesn't have to mess with the code and chunk options to make small edits to text.
Here's an interim solution that lets you retain the speed of making changes directly to the rendered text, but you have to do a little work after you're done making changes.
Assuming the following files:
input.knitr is the original Knitr file with text and code integrated.
output.html is the resulting HTML code that has been rendered by Knitr.
Consider making direct text edits to output.html and then running something like Meld visual merge tool:
meld output.html input.knitr
Then manually select the edits in output.html that are new and should be fixed in the original source input.knitr. Tools such as Meld do a pretty good job of aligning the texts so that the chunks and knitted output will appear as large "changes" that, in practice, you would ignore. You would focus on the small changes in the non-chunk sections.

Resources