Questions tagged [formatr]

The formatR package was designed to reformat R code to improve readability; the main workhorse is the function tidy.source().

The formatR package was designed to reformat R code to improve readability; the main workhorse is the function tidy.source().

The package can be used to reformat R code: spaces and indent will be added to R code automatically, so that the code will be more human-readable and tidy. This package also provides a GUI (by gWidgets) to format R source code.

7 questions
1
vote
1 answer

usage function from formatR removes white space unexpectedly

The usage function from formatr removes white space unexpectedly. See the example below: library(formatR) library(tidyverse) usage( FUN = inner_join , width = getOption("width") , tidy = c(TRUE, FALSE)[1] ,…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
1
vote
1 answer

Is there a way of reformatting all code chunks in an Rmarkdown document?

Is there a way to reformat all code chunks in an Rmarkdown document? I have Rmarkdown documents which need code reformatting but I can't select all and use the Rstudio reformat code.
Ricecakes
  • 681
  • 1
  • 5
  • 13
1
vote
0 answers

Is there a way to call RStudio's code format programmatically?

I'd like to pretty-format an R snippet. There's formatR but because it's based on deparse there's a lot it cannot actually do, pipe operator %>% being one of such things. RStudio has great code formatting capabilities but they don't seem to be…
Lukasz
  • 148
  • 11
1
vote
1 answer

knitr chunk option code to input code into a chunk does not work in R 3.1.1 with knitr 1.6.10

I'm using knitr 1.6.10 in R 3.1.1. The chunk option code seems like does not work. My MWE in .Rnw format is below: \documentclass{article} \begin{document} << packages, include=FALSE, cache=FALSE>>= library(knitr) library(formatR) @ <
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
0
votes
1 answer

Tidying text in a way compatible with tidy evaluation

I want to tidy up source code in a way that is compliant with tidy evaluation. Unfortunately, formatR does not preserve the !! operator. formatR::tidy_source(text = "!!little_b", output = FALSE)$text.tidy ## [1] "!(!little_b)" From Section 7 of…
landau
  • 5,636
  • 1
  • 22
  • 50
0
votes
0 answers

Rstudio built in Reformat code vs addin formatR tidy_source()

I learnt that there are two ways to nicely format R code in RStudio. One listed under Code -> Reformat code. The other is @yihui (formatR:tidy_r source code) which in current Version 0.99.893 of Rstudio, can be added as an addin. I noticed that, the…
user5249203
  • 4,436
  • 1
  • 19
  • 45
0
votes
0 answers

formatR tidy_souce() does not work for clipboard

I have tried the tidy_source() on my windows machine and it worked just fine. However it fails when I try to run tidy_source() on a Ubuntu machine. > sessionInfo() R version 3.2.1 (2015-06-18) Platform: x86_64-pc-linux-gnu (64-bit) Running under:…
GZ-
  • 227
  • 1
  • 11