mwip / beautifyr Goto Github PK
View Code? Open in Web Editor NEWRStudio addin for formatting Rmarkdown tables
License: GNU General Public License v3.0
RStudio addin for formatting Rmarkdown tables
License: GNU General Public License v3.0
I am not sure whether it is worthwhile for you to make this work, but for completeness, I should create this issue:
When Compiling Reports in R, you can basically make use of all Markdown features when writing text after #'
. One of the more common ones that may also need to be beautified is lists:
Here is the example:
#' Unordered List:
#'
#' * Item 1
#' * Item 2
#' + Item 2a
#' + Item 2b
#'
#' Ordered List:
#'
#' 1. Item 1
#' 2. Item 2
#' 3. Item 3
#' + Item 3a
#' + Item 3b
#'
#' An example that actually needs line breaks:
#'
#' 1. Super Mario is a 2D- and 3D-platform game series created by `Nintendo` based on and starring the fictional plumber Mario.
#' 2. Alternatively called the `Super Mario Bros.` series or simply the Mario series, it is the central series of the greater Mario franchise.
#' 3. At least one Super Mario game has been released for every major Nintendo video game console. There are over twenty games in the series.
#' + Super Mario World was released for the Super Nintendo Entertainment System and consists of nine worlds displayed via a world map.
#' + It is a direct successor to the Super Mario Bros. games, bearing the subtitle Super Mario Bros. 4 in Japan.
and this is what beautifyR
currently does:
#' Unordered List: * Item 1 * Item 2 + Item 2a + Item 2b Ordered List: 1. Item
#' 1 2. Item 2 3. Item 3 + Item 3a + Item 3b An example that actually needs
#' line breaks: 1. Super Mario is a 2D- and 3D-platform game series created by
#' `Nintendo` based on and starring the fictional plumber Mario. 2.
#' Alternatively called the `Super Mario Bros.` series or simply the Mario
#' series, it is the central series of the greater Mario franchise. 3. At
#' least one Super Mario game has been released for every major Nintendo video
#' game console. There are over twenty games in the series. + Super Mario
#' World was released for the Super Nintendo Entertainment System and consists
#' of nine worlds displayed via a world map. + It is a direct successor to the
#' Super Mario Bros. games, bearing the subtitle Super Mario Bros. 4 in Japan.
while this is what it should do:
#' Unordered List:
#'
#' * Item 1
#' * Item 2
#' + Item 2a
#' + Item 2b
#'
#' Ordered List:
#'
#' 1. Item 1
#' 2. Item 2
#' 3. Item 3
#' + Item 3a
#' + Item 3b
#'
#' An example that actually needs line breaks:
#'
#' 1. Super Mario is a 2D- and 3D-platform game series created
#' by `Nintendo` based on and starring the fictional plumber
#' Mario.
#' 2. Alternatively called the `Super Mario Bros.` series or simply
#' the Mario series, it is the central series of the greater
#' Mario franchise.
#' 3. At least one Super Mario game has been released for every
#' major Nintendo video game console. There are over twenty
#' games in the series.
#' + Super Mario World was released for the Super Nintendo
#' Entertainment System and consists of nine worlds displayed
#' via a world map.
#' + It is a direct successor to the Super Mario Bros. games,
#' bearing the subtitle Super Mario Bros. 4 in Japan.
But again - feel free to close this issue if this goes beyond what you have in mind for what {beautifyR} is supposed to do.
After installing the package, it is not working for me, i.e. I get an "R code execution error"
The error message in the console:
Error in if (!after) c(values, x) else if (after >= lengx) c(x, values) else c(x[1L:after], :
missing value where TRUE/FALSE needed
This is on RStudio Desktop 1.2.1059. Session Info:
sessioninfo::session_info("beautifyR")
#> - Session info ----------------------------------------------------------
#> setting value
#> version R version 3.5.1 (2018-07-02)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language en
#> collate German_Germany.1252
#> ctype German_Germany.1252
#> tz Europe/Berlin
#> date 2018-11-09
#>
#> - Packages --------------------------------------------------------------
#> package * version date lib source
#> beautifyR 0.2.0 2018-11-09 [1] Github (mwip/beautifyR@f90a04b)
#> glue 1.3.0 2018-07-17 [1] CRAN (R 3.5.1)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.1)
#> rstudioapi 0.8 2018-10-02 [1] CRAN (R 3.5.1)
#> stringi 1.2.4 2018-07-20 [1] CRAN (R 3.5.1)
#> stringr 1.3.1 2018-05-10 [1] CRAN (R 3.5.1)
#>
#> [1] C:/Users/daniel/Documents/.R/win-library
#> [2] C:/Program Files/R/R-3.5.1/library
Currently, beautify comment is hardcoded to respect the column-80 margin. It would be nice to dynamically check the margin set in RStudio via the RStudio::api and beautify comments accordingly.
Indented comments such as
for (i in 1:42) {
# Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
sqrt(i)
}
are currently ignored.
Hi, thanks for the amazing addin!
While trying to beautify tables with emojis, e.g., one like the following-
Analysis | Hypothesis testing | Estimation
------------------ | ---------- | ---------
t-test | ✅ | ✅
one-way ANOVA | ✅ |✅
correlation | ✅ | ✅
I always get the following error:
I am assuming that the emojis are creating problems for the addin?
If second column is the longest, it is assumed as the maxChars. It should not be considered
Hi, thanks for the great addin - I am using Beautify Comment on a regular basis.
However, I find myself manually
-
hyphens/dashes, because they are always removedr mean(c(1,2))
appear on a single lineDo you think there is a better way to handle these?
Someone on Twitter pointed out that RStudio has a built-in shortcut that seems to do the same thing (?) as Beautify Comment. He says it's Ctrl + Shift + /
but for me it is Ctrl + Shift + #
. Nevertheless, it does work 😮
https://twitter.com/SchmidtPaul1989/status/1565600086742138881
After installing RStudio and then the package in my new laptop when I try to use the add-in two types of error message appear in the console. By the way, I have installed a weird RStudio version: RStudio v1.2.830-1 Preview (I wanted to use one of the new features).
The first error message is the following:
Error in cells[[2]] : subscript out of bounds
In addition: Warning message:
In .Primitive("max")() : no non-missing arguments to max; returning -Inf
On my second attempt to use the add-in I get this error:
Warning in beautifyR(con_text) :
Fomatting indicator row 2 (e.g. :----) contains invalid values or is not available
left alignment assumed for all columns
Error in if (!after) c(values, x) else if (after >= lengx) c(x, values) else c(x[1L:after], :
missing value where TRUE/FALSE needed
Do you think the issue is the RStudio version?
UPDATE: I've just tried using the RStudio Version 1.1.456 and I keep getting the same error messages...
Please add a "GIFs generated using [app]" line to your Readme.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.