Embedding scripts in text-editor - unix

I am looking for a text editor that support embedding scripts (Perl in my case) in the text you write.
I understand that something like it is possible through Emacs, but am not sure how and what.
The idea is to generate reports that contain the output of the embedded scripts, which are run while generating the report (if not already in previous versions of the report).

The Babel package in Emacs can do this. See the introductory tutorial here.

sweave does that in a limited way (R only).

Related

Indenting VSCode like RStudio

I'm using VS Code and i miss RStudio's ctrl+i to indent lines.
I've read stuff online about LSP and other extensions and formatting with shift+alt+F but all i get is linter.
So, whats the equivalent if is there at all?
Found a solution but there a few things to take note.
First, VSCode notive options are language-agnostic, meaning it can't indent R code 'cause it doesn't understand it. You got to download extensions to make i work.
Extensions required are
Yuki Ueda's R for language support
REditorSupport's R LSP Client
Also, in order to R LSP Client to work, CRAN package {languageserver} is required.
Then, usage. If you're working functions, differently from RStudio in which one can hit ctrl+i and that'd indent that specifically line or selection, this solution works only if one selects the entire function. If you have functions inside another, you gotta indent everything (won't work for just a foo inside another).

Can Roxygen really document R script (not a package) just like Doxygen does for C++?

Roxygen is inspired by the Doxygen documentation system that is used by C, C++ programmers. I have used Doxygen and I find it really easy to document any program as long as you have the doxygen comment. It also generate call graphs for functions and classes. I thought roxygen would work the same way but when I search for roxygen help, I only find solution to documenting R packages.
I have checked Hadley Wickham's online roxygen2 help but that does not describe anything about the R script documentation.
My scripts sometimes become 500-1000 lines and have several functions which I always document with the comments. I want to generate PDF or HTML documentation with graph-viz diagrams. Is Roxygen capable of making call-graph and document standalone R scripts?
No, roxygen2 will work only for writing package documentation. Sounds to me you're after a report generating tool. You can use knitr for that. You can include code, comments, text, MathJax, or even use LaTeX. It also supports table of contents and references. This is by no means an exhaustive list of functionality. With some logical limitations, you can produce pdf and html documents, among others.
Though this is an old thread, for future reference, the following library is able to achieve that:
https://rdrr.io/cran/document/
From its docs: Have you ever been tempted to create 'roxygen2'-style documentation comments for one of your functions that was not part of one of your packages (yet)? This is exactly what this package is about: running 'roxygen2' on (chunks of) a single code file.

Change default skeletons for RStudio

RStudio has a wonderful set of skeletons for packages and Rmd documents. But, I'd like to know if it's possible to change the defaults to a "skeleton" of your own design. If, like me, you package your research for yourself/clients, you quickly find yourself deleting and copying the same work over and over.
I suppose there are two related questions here:
Can you change the default package skeleton?
Can you change the default Rmd skeleton?
There is no supported way to do this. However, the skeletons are stored as ordinary files in your filesystem, so there's nothing stopping you from modifying them. For instance, if you're on the Mac, this file provides the default Rmd skeleton:
/Applications/RStudio.app/Contents/Resources/resources/templates/r_markdown_v2.Rmd
On Windows, it's here:
C:\Program Files\RStudio\resources\templates\r_markdown_v2.Rmd
I didn't realize it then, but I was actually looking for a custom format. The details of which are documented extensively on the rmarkdown rstudio site.
http://rmarkdown.rstudio.com/developer_custom_formats.html

Compiling *.Rnw files with knitr --without Rstudio

I would like to use knitr to create presentations that embed R objects and code.
For IT reasons I am restricted to vim, so i have found the available Rstudio+knitr examples fairly unhelpful. The vim section of the knitr documents is also very skinny, and therefore unhelpful.
Is someone able to provide some guidance on how to compile a *.Rnw or *.Rmd file using knitr (or alternately point me to a decent online tutorial?) using some combination of vim, R, and the command line?
thanks in advance
Instead of going through Rstudio, you can use the functions in the knitr package directly. There are some options you can tweak, but to get started, all you have to do is call the knit() function on your .Rnw file:
library(knitr)
knit('my_input.Rnw')
If you're missing some of Rstudio's features, it's worth remembering that most of them are just making use of things that are already available in various R packages, so you can usually find a way to use them when you don't have Rstudio available.

Rreport/LaTeX quality output package

I'm looking for some LaTeX template for creating quality output. On R-bloggers I've bumped on Frank Harrel's Rreport package. Due to my quite modest LaTeX abilities, only a user-friendly (and noob-friendly) interface should suffice. Here's a link to an official website. I'm following the instructions, but I cannot manage to install an app. I use Ubuntu 9.10, R version is 2.10.1 (updated regularly from UCLA's CRAN server), and of course, cvs is installed on my system.
Now, I'd like to know if there is some user-friendly LaTeX template package (Sweave is still to advanced/spartan for me). I'm aware that my question is quite confounding, but a brief glance on examples on Rreport page should give you a hint. I'm aware that LaTeX skills are a must, but just for now I need something that will suit my needs (as a psychological researcher).
Is there any package similar with Rreport?
lyx? http://www.lyx.org/
On Ubuntu:
sudo apt-get install lyx
From the lyx page:
LyX combines the power and flexibility
of TeX/LaTeX with the ease of use of a
graphical interface. This results in
world-class support for creation of
mathematical content (via a fully
integrated equation editor) and
structured documents like academic
articles, theses, and books.
If you want to produce Latex with a simpler markup you could use the ASCII package that has a Sweave driver that can be used with reSTructured text, which can then be converted to Latex. Although I would only use it if you want to be able to convert the same doc also to html or odf. In any case it is a good idea to learn the basic Latex.
The online text processor zoho allows export to latex. Maybe this can be helpful to learn latex, but I do not know how to integrate Sweave/R in this. (I did not work with zoho, by the way).

Resources