MyNixOS website logo
Description

To Insert Title, Divider, and Block of Comments.

For instructions, check <https://github.com/Hzhang-ouce/ARTofR>. This is a wrapper of 'bannerCommenter', for inserting neat comments, headers and dividers.

Who ever care about the [art of R] scripts?

Travis buildstatus R-CMD-check

ARTofR is designed to make something like this:

#........................ARTofR line break.......................

It is a wrapper of bannerCommenter::banner(), written with thanks to the author, Bill Venables

Installation

Install from CRAN:

install.packages("ARTofR")

OR you can install the beta version of ARTofR from GitHub with:

# install.packages("devtools")
devtools::install_github("Hzhang-ouce/ARTofR")

Usage 1 - copy and paste

  1. type your text in any text editor
  2. copy your text
  3. call xxx_box() or xxx_box1() etc without arguments in R console
  4. NO NEED to copy again!!!
  5. paste into your R script

For example: image

Usage 2 - hand-typing

xxx_title2('your title')


##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##                                  your title                              ----
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


xxx_box1('your comments')


#...............................................................................
#                                                                              .
#  your comments                                                               .
#                                                                              .
#...............................................................................

FUNCTION1: xxx_title

xxx_title() will automatically bring you a navigation panel

but xxx_divider will not

For example: this

  library(ARTofR)
  xxx_title0('ARTofR')

##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##                                                                            ~~
##                                   ARTOFR                                 ----
##                                                                            ~~
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  xxx_title1('ARTofR')

##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##                                                                            --
##...................................ARTOFR.................................----
##                                                                            --
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  xxx_title2('ARTofR')

##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##                                   ARTofR                                 ----
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  xxx_title3('ARTofR')
  
##~~~~~~~~~~~~~~~~
##  ~ ARTofR  ----
##~~~~~~~~~~~~~~~~

FUNCTION2: xxx_divider

You need to turn-off auto-indent in options\code of R studio, to keep the spaces before the line break

  library(ARTofR)
  xxx_divider1('')
  
     #................................................................

  xxx_divider1('ARTofR')

     #.............................ARTofR.............................

  xxx_divider2('')     
     
     ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
  xxx_divider2('ARTofR')
     
     #                            ARTofR                            ~~~
     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

FUNCTION3: xxx_box

Copy this paragraph:

I used ARTofR everyday and it makes my R script so neat. I used ARTofR everyday and it makes my R script so neat. I used ARTofR everyday and it makes my R script so neat.
I recommended this pacakge to all my families.
Yes, even my grandmother like it!

Then in your R console do:

  xxx_box()

#  I used ARTofR everyday and it makes my R script so neat. I used ARTofR       
#  everyday and it makes my R script so neat. I used ARTofR everyday and it     
#  makes my R script so neat.                                                   
#                                                                               
#  I recommended this pacakge to all my families.                               
#                                                                               
#  Yes, even my grandmother like it!                                        


  xxx_box1()
  
#...............................................................................
#                                                                              .
#  I used ARTofR everyday and it makes my R script so neat. I used ARTofR      .
#  everyday and it makes my R script so neat. I used ARTofR everyday and it    .
#  makes my R script so neat.                                                  .
#                                                                              .
#  I recommended this pacakge to all my families.                              .
#                                                                              .
#  Yes, even my grandmother like it!                                           .
#                                                                              .
#...............................................................................


  xxx_box1(center = T)
  
#...............................................................................
#                                                                              .
#    I used ARTofR everyday and it makes my R script so neat. I used ARTofR    .
#   everyday and it makes my R script so neat. I used ARTofR everyday and it   .
#                          makes my R script so neat.                          .
#                                                                              .
#                I recommended this pacakge to all my families.                .
#                                                                              .
#                      Yes, even my grandmother like it!                       .
#                                                                              .
#...............................................................................

FUNCTION4: xxx_list

Copy this list:

1. I used ARTofR everyday
2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR everyday and it makes my R script so neat.
3. I recommended this pacakge to all my families. I recommended this pacakge to all my families.
4. Yes, even my grandmother like it!

Then in your R console:

  xxx_list()

#  1. I used ARTofR everyday                                                
#  2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR
#     everyday and it makes my R script so neat.                            
#  3. I recommended this pacakge to all my families. I recommended this     
#     pacakge to all my families.                                           
#  4. Yes, even my grandmother like it!                                     

  xxx_list1()
  
#...............................................................................
#                                                                              .
#  1. I used ARTofR everyday                                                   .
#  2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR   .
#     everyday and it makes my R script so neat.                               .
#  3. I recommended this pacakge to all my families. I recommended this        .
#     pacakge to all my families.                                              .
#  4. Yes, even my grandmother like it!                                        .
#                                                                              .
#...............................................................................

xxx_list1(center = T) is not recommended, use xxx_box(center=T)

Tips and warnings:

  • Only Mac and windows were tested with this package.
  • For all functions, you can use, for example, xxx_divider2(’’) in non-interactive mode to insert a break line in your text output
  • Once text was decorated, it would be difficult to restore. It is best to save your text in a plain-text file and copy from there, so that you can modify in the future.

Motivation:

There is a gratuitous advice in BannerCommenter help doc saying: ‘A potential danger of providing this simple facility is that some authors may be tempted to overdo their script decoration.’

These set of functions, being a wrapper of banner, was designed to

  1. Achieve a balance between simplicity and complexity
  2. Make use of Rstudio section tag and build a hierarchy
  3. From clipboard to clipboard (e.g. call xxx_box() with no input, last texts in clipboard will be grabbed into the function)
  4. It was called xxx so that it can be distinguished from any other R packages.

Other packages

Here are some other pacakages I found useful for R codes formatting:

strcodestylerbannercommenter.

Metadata

Version

0.4.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows