├── .github ├── .gitignore └── workflows │ └── R-CMD-check.yaml ├── vignettes ├── .gitignore └── User_guide.Rmd ├── LICENSE ├── CambridgePoster.pdf ├── Screenshot13809.png ├── Screenshot138092.png ├── .gitignore ├── Screenshot2022-03-06175714.png ├── WeChatImage_20220306175401.png ├── .travis.yml ├── CRAN-RELEASE ├── inst └── rstudio │ └── addins.dcf ├── .Rbuildignore ├── NAMESPACE ├── ARTofR.Rproj ├── NEWS.md ├── DESCRIPTION ├── LICENSE.md ├── R ├── app.R ├── xxx_divider.R ├── xxx_title.R ├── xxx_box.R └── my_own_banner.R ├── man ├── xxx_divider1.Rd ├── xxx_title1.Rd ├── xxx_box.Rd └── my_own_banner.Rd ├── cran-comments.md ├── README.md └── README.Rmd /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2021 2 | COPYRIGHT HOLDER: Huanyuan Zhang 3 | -------------------------------------------------------------------------------- /CambridgePoster.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/HEAD/CambridgePoster.pdf -------------------------------------------------------------------------------- /Screenshot13809.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/HEAD/Screenshot13809.png -------------------------------------------------------------------------------- /Screenshot138092.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/HEAD/Screenshot138092.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .Rdata 4 | .httr-oauth 5 | .DS_Store 6 | inst/doc 7 | /doc/ 8 | /Meta/ 9 | -------------------------------------------------------------------------------- /Screenshot2022-03-06175714.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/HEAD/Screenshot2022-03-06175714.png -------------------------------------------------------------------------------- /WeChatImage_20220306175401.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/HEAD/WeChatImage_20220306175401.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | cache: packages 5 | -------------------------------------------------------------------------------- /CRAN-RELEASE: -------------------------------------------------------------------------------- 1 | This package was submitted to CRAN on 2022-03-05. 2 | Once it is accepted, delete this file and tag the release (commit 87879bb). 3 | -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | Name: ARTofR user interface 2 | Description: help to trigger ARTofR functions 3 | Binding: ARTofR_user_interface 4 | Interactive: true 5 | 6 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^ARTofR\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^LICENSE\.md$ 4 | ^README\.Rmd$ 5 | ^doc$ 6 | ^Meta$ 7 | ^\.travis\.yml$ 8 | ^\.github$ 9 | ^Screenshot13809\.png$ 10 | ^Screenshot138092\.png$ 11 | ^WeChatImage_20220306175401\.png$ 12 | ^Screenshot2022-03-06175714\.png$ 13 | ^cran-comments\.md$ 14 | ^CRAN-RELEASE$ 15 | 16 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(my_own_banner) 4 | export(xxx_box) 5 | export(xxx_box1) 6 | export(xxx_divider1) 7 | export(xxx_divider2) 8 | export(xxx_list) 9 | export(xxx_list1) 10 | export(xxx_title0) 11 | export(xxx_title1) 12 | export(xxx_title2) 13 | export(xxx_title3) 14 | import(bannerCommenter) 15 | import(shiny) 16 | -------------------------------------------------------------------------------- /ARTofR.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | LineEndingConversion: Posix 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | 2 | # ARTofR 0.1.0 3 | 4 | * Hzhang 01/09/2021 5 | * The package used to work by auto-read a txt file, now has been changed into auto-read clipboard 6 | 7 | 8 | # ARTofR 0.2.2 9 | 10 | * Hzhang 01/10/2021 11 | * Remove dependency of stringr pacakge by writing a simple fold_it function in the package. 12 | * First submission to CRAN. 13 | 14 | # ARTofR 0.2.3 15 | 16 | * Better instruction! 17 | * Now xxx_box will try to eliminate empty row, keep only one space between paragraph 18 | * Correct xxx_divider that produces lines with different length 19 | 20 | 21 | # ARTofR 0.3.3 22 | 23 | * fix the title2 and title 1 centre problem, now they are perfectly centered 24 | * add xxx_title0 new style 25 | 26 | # ARTofR 0.4.1 27 | 28 | * Add user interface, to easily apply functions 29 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: ARTofR 2 | Title: To Insert Title, Divider, and Block of Comments 3 | Version: 0.4.2 4 | Authors@R: 5 | person(given = "Huanyuan", 6 | family = "Zhang", 7 | role = c("aut", "cre"), 8 | email = "hyzhang1996@gmail.com", 9 | comment = c(ORCID = "0000-0003-4801-8771")) 10 | Description: For instructions, check . This is a wrapper of 'bannerCommenter', for inserting neat comments, headers and dividers. 11 | License: MIT + file LICENSE 12 | Encoding: UTF-8 13 | LazyData: true 14 | Roxygen: list(markdown = TRUE) 15 | RoxygenNote: 7.1.2 16 | Imports: 17 | bannerCommenter (>= 1.0.0), 18 | clipr (>= 0.4.0), 19 | rstudioapi, 20 | shiny 21 | Suggests: 22 | rmarkdown, 23 | miniUI, 24 | knitr 25 | VignetteBuilder: knitr 26 | Date: 2022-03-05 23:20:01 UTC 27 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2021 Huanyuan Zhang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /R/app.R: -------------------------------------------------------------------------------- 1 | #' @import shiny 2 | ARTofR_user_interface <- function() { 3 | ART_of_R_functions <- c("title1", "title2", "title3", "divider1", "divider2",'box','box1','list','list1') 4 | 5 | ui <- fluidPage( 6 | HTML("
DESCRIPTION"), 7 | HTML("
1. Use this app to insert title, divider, or box of comments into your script"), 8 | HTML("
2. Start by choosing a decoration style"), 9 | HTML("
3. Copy the text you want and click 'Use clipboard'"), 10 | HTML("
4. OR, you can just type your text and click 'OK'"), 11 | HTML("
5. See results in your console! All results are auto copied and ready to paste"), 12 | radioButtons("STYLE", "Select your decoration:", ART_of_R_functions,inline=TRUE), 13 | HTML("
"), 14 | actionButton("clipboard", "Use clipboard"), 15 | HTML("
"), 16 | textInput("userinput",""), 17 | actionButton("WORDS", "OK"), 18 | HTML("
Tips: choose divider and click OK to get a simple line"), 19 | HTML("
Tips2: for more information, check: ARTofR guide") 20 | 21 | ) 22 | server <- function(input, output, session) { 23 | 24 | observe({ 25 | if (input$clipboard) { 26 | rstudioapi::callFun("sendToConsole",paste0('ARTofR::xxx_',input$STYLE,'()')) 27 | stopApp() 28 | } 29 | }) 30 | observe({ 31 | if (input$WORDS) { 32 | rstudioapi::callFun("sendToConsole",paste0('ARTofR::xxx_',input$STYLE,'(\"',input$userinput,'\")')) 33 | stopApp() 34 | } 35 | }) 36 | 37 | } 38 | 39 | viewer <- dialogViewer('ARTofR') 40 | runGadget(ui, server, viewer = viewer) 41 | } 42 | 43 | 44 | "2022-03-04 17:31:21" 45 | -------------------------------------------------------------------------------- /vignettes/User_guide.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "To Insert Title, Divider, and Block of Comments" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{User_guide} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>" 14 | ) 15 | ``` 16 | 17 | ## ARTofR 18 | 19 | Have you ever typed something like this in your R script as a section break: 20 | 21 | ```r 22 | 23 | #.........................just a example......................... 24 | 25 | 26 | ``` 27 | 28 | ARTofR is designed to help you do this, by auto-inserting title, divider and block of comments, for example: 29 | 30 | `xxx_divider1('just a example')` will give you 31 | 32 | ```r 33 | 34 | #.........................just a example......................... 35 | 36 | 37 | ``` 38 | 39 | `xxx_title2('another example')` will give you 40 | 41 | ```r 42 | 43 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 44 | ## another example ---- 45 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 | 47 | 48 | ``` 49 | 50 | ARTofR is a wrapper of bannerCommenter::banner(), written with thanks to the author, Bill Venables 51 | 52 | ## Installation 53 | 54 | Install from CRAN: 55 | 56 | ``` r 57 | install.packages('ARTofR') 58 | ``` 59 | 60 | Install the developing version of ARTofR: 61 | 62 | ``` r 63 | # install.packages("devtools") 64 | devtools::install_github("Hzhang-ouce/ARTofR") 65 | ``` 66 | 67 | ## Complete user guide: 68 | 69 | **User guide at** [Hzhang-ouce-ARTofR](https://github.com/Hzhang-ouce/ARTofR) 70 | 71 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macOS-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - uses: r-lib/actions/setup-pandoc@v1 35 | 36 | - uses: r-lib/actions/setup-r@v1 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v1 43 | with: 44 | extra-packages: rcmdcheck 45 | 46 | - uses: r-lib/actions/check-r-package@v1 47 | 48 | - name: Show testthat output 49 | if: always() 50 | run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true 51 | shell: bash 52 | 53 | - name: Upload check results 54 | if: failure() 55 | uses: actions/upload-artifact@main 56 | with: 57 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 58 | path: check 59 | -------------------------------------------------------------------------------- /man/xxx_divider1.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/xxx_divider.R 3 | \name{xxx_divider1} 4 | \alias{xxx_divider1} 5 | \alias{xxx_divider2} 6 | \title{Insert a divider (line break or page break)} 7 | \usage{ 8 | xxx_divider1(mystring = NULL) 9 | 10 | xxx_divider2(mystring = NULL) 11 | } 12 | \arguments{ 13 | \item{mystring}{the content of your break, must be one line only, not too long} 14 | } 15 | \value{ 16 | A character string vector returned invisibly, 17 | but automatically displayed in the console, the output will be saved into clipboard 18 | } 19 | \description{ 20 | For user guide, please refer to \url{https://github.com/Hzhang-ouce/ARTofR}\cr 21 | } 22 | \details{ 23 | Divider is shorter than title for hierarchy purpose, title will be come a section (for folding) in Rstudio, but divider will not\cr 24 | There are two styles of break, xxx_divider1 and xxx_divider2 \cr 25 | Please note that a super long divider string will result in an error\cr 26 | call \code{xxx_divider1()} will grab text from clipboard,\cr 27 | call \code{xxx_divider1('')} will make a line without text, \cr 28 | call \code{xxx_divider1('mystring')} will make a divider with 'mystring' 29 | } 30 | \section{Functions}{ 31 | \itemize{ 32 | \item \code{xxx_divider2}: Same as xxx_divider1 but different style 33 | }} 34 | 35 | \examples{ 36 | # COMMON WORKFLOW OF THIS PACKAGE 37 | # 38 | # 1. To insert Dividers with your own text 39 | # 2. copy the text you want from anywhere 40 | # 3. call xxx_divider1() etc without arguments to grab text from clipboard 41 | # 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them 42 | # 5. paste it into your R script 43 | #............................................... 44 | # # SPECIFIC USAGE EXAMPLE: 45 | 46 | xxx_divider1('mystring') 47 | xxx_divider1('') 48 | xxx_divider2('mystring') 49 | xxx_divider2('') 50 | } 51 | -------------------------------------------------------------------------------- /man/xxx_title1.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/xxx_title.R 3 | \name{xxx_title1} 4 | \alias{xxx_title1} 5 | \alias{xxx_title0} 6 | \alias{xxx_title2} 7 | \alias{xxx_title3} 8 | \title{Insert a title} 9 | \usage{ 10 | xxx_title1(mystring = NULL) 11 | 12 | xxx_title0(mystring = NULL) 13 | 14 | xxx_title2(mystring = NULL) 15 | 16 | xxx_title3(mystring = NULL) 17 | } 18 | \arguments{ 19 | \item{mystring}{the content of your title, must be one line only, not too long} 20 | } 21 | \value{ 22 | A character string vector returned invisibly, 23 | but automatically displayed in the console, the output will be saved into clipboard 24 | } 25 | \description{ 26 | For user guide, please refer to \url{https://github.com/Hzhang-ouce/ARTofR}\cr 27 | } 28 | \details{ 29 | There are three levels of titles, inserting a title with xxx_title() will also add a section in Rstudio automatically.\cr 30 | Please note that a super long title string will result in an error\cr 31 | xxx_title0() was designed as the main title of the whole script\cr 32 | xxx_title1() is the largest header\cr 33 | xxx_title2() is the middle size header\cr 34 | xxx_title3() is the smallest header\cr 35 | } 36 | \section{Functions}{ 37 | \itemize{ 38 | \item \code{xxx_title0}: the middle size title 39 | 40 | \item \code{xxx_title2}: the middle size title 41 | 42 | \item \code{xxx_title3}: the smallest title 43 | }} 44 | 45 | \examples{ 46 | # COMMON WORKFLOW OF THIS PACKAGE 47 | # 48 | # 1. To insert titles with your own text 49 | # 2. copy the text you want from anywhere 50 | # 3. call xxx_title2() etc without arguments to grab text from clipboard 51 | # 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them 52 | # 5. paste it into your R script 53 | #............................................... 54 | # # SPECIFIC USAGE EXAMPLE: 55 | 56 | xxx_title0('my title') 57 | xxx_title1('my title') 58 | xxx_title2('my title') 59 | xxx_title3('my title') 60 | 61 | } 62 | -------------------------------------------------------------------------------- /man/xxx_box.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/xxx_box.R 3 | \name{xxx_box} 4 | \alias{xxx_box} 5 | \alias{xxx_box1} 6 | \alias{xxx_list} 7 | \alias{xxx_list1} 8 | \title{Convert sentences into a box of comments} 9 | \usage{ 10 | xxx_box(mystring = NULL, center = FALSE) 11 | 12 | xxx_box1(mystring = NULL, center = FALSE) 13 | 14 | xxx_list(mystring = NULL, center = FALSE) 15 | 16 | xxx_list1(mystring = NULL, center = FALSE) 17 | } 18 | \arguments{ 19 | \item{mystring}{A string, will be a line of comment. If missing, the function will try to grab texts from your clipboard.} 20 | 21 | \item{center}{A logical value: Do you want the text strings centred? 22 | (alternative: left justified)} 23 | } 24 | \value{ 25 | A character string vector returned invisibly, 26 | but automatically displayed in the console, the output will be saved into clipboard 27 | } 28 | \description{ 29 | For user guide, please refer to \url{https://github.com/Hzhang-ouce/ARTofR}\cr 30 | } 31 | \details{ 32 | xxx_box is for paragraph, xxx_list is for bullet points or numbered list.\cr 33 | Number 1 in xxx_box1 and xxx_list1 imply style 1.\cr 34 | } 35 | \section{Functions}{ 36 | \itemize{ 37 | \item \code{xxx_box1}: Same as xxx_box but add border 38 | 39 | \item \code{xxx_list}: Same as xxx_box but looks better for bullet points list or numbered list 40 | 41 | \item \code{xxx_list1}: Same as xxx_list but add border 42 | }} 43 | 44 | \examples{ 45 | # COMMON WORKFLOW OF THIS PACKAGE 46 | # 47 | # 1. To insert a box of comments etc with your own text 48 | # 2. copy the text you want from anywhere 49 | # 3. call xxx_box1() etc without arguments to grab text from clipboard 50 | # 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them 51 | # 5. paste it into your R script 52 | #............................................... 53 | # # SPECIFIC USAGE EXAMPLE: 54 | 55 | xxx_box('test sentence, test sentence, test sentence, test sentence',center = FALSE ) 56 | xxx_box1('test sentence, test sentence, test sentence, test sentence',center = FALSE ) 57 | xxx_box1('test sentence, test sentence, test sentence, test sentence',center = TRUE ) 58 | } 59 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | # Hzhang 22/10/2021, V0.4.1 2 | 3 | ## Test environments 4 | * local check() - all passed 5 | * check_rhub() and check_win_devel() - passed with minor notes, already fixed 6 | 7 | ## Updates 8 | * Put a user interface as Rstudio addins 9 | * The addins basically help to composite commands and send ARTofR commands to console 10 | 11 | 12 | #......................Previous submission....................... 13 | 14 | # Hzhang 22/10/2021, V0.3.3 15 | 16 | ## Test environments 17 | * local check() - all passed 18 | * travis-ci - all passed 19 | 20 | ## Updates 21 | * fix the title2 and title 1 centre problem, now they are perfectly centered 22 | * add xxx_title0 new style 23 | 24 | # Hzhang 03/10/2021, V0.2.3 25 | 26 | ## Test environments 27 | * local check() - all passed 28 | * travis-ci - all passed 29 | * check_rhub() - one note about CRAN incoming feasibility 30 | 31 | ## Updates 32 | * This small update is to improve user instructions. 33 | * Also fix a small bug in xxx_divider() which cause wrong alignment 34 | * Solve the "NOTE" on CRAN check 35 | 36 | # Hzhang 01/10/2021, V0.2.2 37 | 38 | ## Test environments 39 | * local OS X install, R 4.1.1 40 | * Ubuntu 16.04.6 LTS (on travis-ci), R version 4.0.2 (2020-06-22) 41 | * windows 10 install, r 4.1.1 42 | 43 | ## R CMD check results 44 | There were no ERRORs nor WARNINGs nor notes on Travis. 45 | 46 | -- R CMD check results ---- ARTofR 0.2.2 ---- 47 | Duration: 19.4s 48 | 49 | Also no ERRORs nor WARNINGs nor notes on my local machine 50 | 51 | ## Downstream dependencies 52 | No relevant, this is the first submission 53 | 54 | ## Updates 55 | 56 | write TRUE and FALSE instead of T and F. 57 | 58 | Some code lines in examples are commented out in xxx_box.Rd, 59 | xxx_divider2.Rd, xxx_title1.Rd. Now # removed 60 | 61 | # Hzhang 30/09/2021 62 | 63 | ## Test environments 64 | * local OS X install, R 4.1.1 65 | * Ubuntu 16.04.6 LTS (on travis-ci), R version 4.0.2 (2020-06-22) 66 | * windows 10 install, r 4.1.1 67 | 68 | ## R CMD check results 69 | There were no ERRORs nor WARNINGs nor notes on Travis. 70 | 71 | -- R CMD check results ---- ARTofR 0.2.1 ---- 72 | Duration: 16.4s 73 | 74 | Also no ERRORs nor WARNINGs nor notes on my local machine 75 | 76 | ## Downstream dependencies 77 | No relevant, this is the first submission 78 | -------------------------------------------------------------------------------- /man/my_own_banner.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/my_own_banner.R 3 | \name{my_own_banner} 4 | \alias{my_own_banner} 5 | \alias{fold_it} 6 | \title{Core functions for comment making} 7 | \usage{ 8 | my_own_banner( 9 | x, 10 | ..., 11 | emph = FALSE, 12 | snug = FALSE, 13 | upper = emph, 14 | centre = !fold, 15 | leftSideHashes = 2 + emph, 16 | rightSideHashes = leftSideHashes, 17 | minHashes = (!snug) * (80 + 10 * emph), 18 | numLines = 1 + emph, 19 | bandChar = "#", 20 | center = centre, 21 | fold = FALSE, 22 | maxChar = 75 23 | ) 24 | 25 | fold_it(x, maxChar, exdent = 0) 26 | } 27 | \arguments{ 28 | \item{x}{the string} 29 | 30 | \item{...}{Zero or more additional strings as extra lines. Strings may contain 31 | newline characters resulting in further line breaks.} 32 | 33 | \item{emph}{A logical value: Do you want this to be an emphasised comment?} 34 | 35 | \item{snug}{A logical value: Do you want the decoration to hug the strings closely?} 36 | 37 | \item{upper}{A logical value: Do you want the strings converted to upper case?} 38 | 39 | \item{centre}{A logical value: Do you want the text strings centred? 40 | (alternative: left justified)} 41 | 42 | \item{leftSideHashes}{A positive integer: How many hashes go on the left side?} 43 | 44 | \item{rightSideHashes}{A non-negative integer: How many hashes go on the right side?} 45 | 46 | \item{minHashes}{A non-negative integer: What is the minimum number of hashes 47 | in the boundary lines?} 48 | 49 | \item{numLines}{A non-negative integer: How many lines of hashes above 50 | and below do you want?} 51 | 52 | \item{bandChar}{A single character. Used instead of # for all characters in 53 | the bands around the text, apart from the first character of every line.} 54 | 55 | \item{center}{Alternative spelling of \code{centre}.} 56 | 57 | \item{fold}{Logical: should the text be folded to ensure lines are not too long?} 58 | 59 | \item{maxChar}{same as width in str_wrap} 60 | 61 | \item{exdent}{for xxx_list()} 62 | } 63 | \value{ 64 | A character string vector returned invisibly, 65 | but automatically displayed in the console 66 | 67 | 68 | } 69 | \description{ 70 | This is modified from \code{bannerCommenter::banner()}, the main modification is to extend the comment length (minHashes) to 80 71 | } 72 | \section{Functions}{ 73 | \itemize{ 74 | \item \code{fold_it}: sub-function to fold sentence, don't use this in other circumstance 75 | }} 76 | 77 | \examples{ 78 | my_own_banner("This should appear clearly and stand out.", 79 | "The lines are left justified by default.") 80 | ##This is NOT recommended!!! 81 | ##This is NOT recommended!!! 82 | ##This is NOT recommended!!! 83 | ##pls use bannerCommenter::banner() 84 | } 85 | \keyword{internal} 86 | -------------------------------------------------------------------------------- /R/xxx_divider.R: -------------------------------------------------------------------------------- 1 | #' Insert a divider (line break or page break) 2 | #' 3 | #' For user guide, please refer to \cr 4 | #' 5 | #' 6 | #' Divider is shorter than title for hierarchy purpose, title will be come a section (for folding) in Rstudio, but divider will not\cr 7 | #' There are two styles of break, xxx_divider1 and xxx_divider2 \cr 8 | #' Please note that a super long divider string will result in an error\cr 9 | #' call \code{xxx_divider1()} will grab text from clipboard,\cr 10 | #' call \code{xxx_divider1('')} will make a line without text, \cr 11 | #' call \code{xxx_divider1('mystring')} will make a divider with 'mystring' 12 | #' 13 | #' @param mystring the content of your break, must be one line only, not too long 14 | #' 15 | #' @return A character string vector returned invisibly, 16 | #' but automatically displayed in the console, the output will be saved into clipboard 17 | #' @export 18 | #' 19 | #' @examples 20 | #' # COMMON WORKFLOW OF THIS PACKAGE 21 | #' # 22 | #' # 1. To insert Dividers with your own text 23 | #' # 2. copy the text you want from anywhere 24 | #' # 3. call xxx_divider1() etc without arguments to grab text from clipboard 25 | #' # 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them 26 | #' # 5. paste it into your R script 27 | #' #............................................... 28 | #' # # SPECIFIC USAGE EXAMPLE: 29 | #' 30 | #' xxx_divider1('mystring') 31 | #' xxx_divider1('') 32 | #' xxx_divider2('mystring') 33 | #' xxx_divider2('') 34 | xxx_divider1<-function(mystring=NULL){ 35 | if (is.null(mystring)) { 36 | mystring<-clipr::read_clip(allow_non_interactive = Sys.getenv("CLIPR_ALLOW", interactive())) 37 | mystring<-mystring[1] 38 | } 39 | text <- mystring 40 | if (length(text) == 0) { text <- ""} 41 | nt <- 1 42 | kt <- 1 43 | n0 <- nchar(text) 44 | leftHash='#' 45 | leftSideHashes=nchar(leftHash) 46 | rightHash='' 47 | rightSideHashes=nchar(rightHash) 48 | mid <- character(nt) 49 | hashes = 65 50 | blanks <- (hashes - leftSideHashes - rightSideHashes - n0) 51 | if (blanks<0) { 52 | stop('you must provide a sentence less than 65 character') 53 | } 54 | blanks1 = round(blanks/2) 55 | blanks2 <- blanks - blanks1 56 | left <- paste(c(' ',leftHash, rep(".", blanks1)), collapse = "") 57 | right <- paste(c(rep(".", blanks2), rightHash), collapse = "") 58 | mid <- paste(left, text, right, sep = "", collapse = "") 59 | structure(mid, class = "banner") 60 | #print.banner2(mid) 61 | } 62 | 63 | #' @describeIn xxx_divider1 Same as xxx_divider1 but different style 64 | #' 65 | #' @export 66 | xxx_divider2<-function(mystring=NULL){ 67 | if (is.null(mystring)) { 68 | mystring<-clipr::read_clip(allow_non_interactive = Sys.getenv("CLIPR_ALLOW", interactive())) 69 | mystring<-mystring[1] 70 | } 71 | if (nchar(mystring)==0) { 72 | comment<-my_own_banner("",leftSideHashes=1,bandChar = '~',minHashes=65) 73 | structure(paste0(' ',comment), class = "banner") 74 | 75 | }else{ 76 | a<-my_own_banner(mystring,bandChar = '~',numLines=0,rightSideHashes=3,leftSideHashes=1,minHashes=65) 77 | b<-my_own_banner("",leftSideHashes=1,bandChar = '~',minHashes=65) 78 | comment<-paste0(' ',a,' ',b) 79 | structure(comment, class = "banner") 80 | } 81 | } 82 | 83 | 84 | 85 | 86 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /R/xxx_title.R: -------------------------------------------------------------------------------- 1 | 2 | #' Insert a title 3 | #' 4 | #' For user guide, please refer to \cr 5 | #' 6 | #' There are three levels of titles, inserting a title with xxx_title() will also add a section in Rstudio automatically.\cr 7 | #' Please note that a super long title string will result in an error\cr 8 | #' xxx_title0() was designed as the main title of the whole script\cr 9 | #' xxx_title1() is the largest header\cr 10 | #' xxx_title2() is the middle size header\cr 11 | #' xxx_title3() is the smallest header\cr 12 | #' 13 | #' @param mystring the content of your title, must be one line only, not too long 14 | #' 15 | #' @return A character string vector returned invisibly, 16 | #' but automatically displayed in the console, the output will be saved into clipboard 17 | #' @export 18 | #' 19 | #' @examples 20 | #' # COMMON WORKFLOW OF THIS PACKAGE 21 | #' # 22 | #' # 1. To insert titles with your own text 23 | #' # 2. copy the text you want from anywhere 24 | #' # 3. call xxx_title2() etc without arguments to grab text from clipboard 25 | #' # 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them 26 | #' # 5. paste it into your R script 27 | #' #............................................... 28 | #' # # SPECIFIC USAGE EXAMPLE: 29 | #' 30 | #' xxx_title0('my title') 31 | #' xxx_title1('my title') 32 | #' xxx_title2('my title') 33 | #' xxx_title3('my title') 34 | #' 35 | xxx_title1<-function(mystring=NULL){ 36 | if (is.null(mystring)) { 37 | mystring<-clipr::read_clip(allow_non_interactive = Sys.getenv("CLIPR_ALLOW", interactive())) 38 | } 39 | my_out_string<-my_own_banner(mystring, numLines = 2,upper=T, bandChar='~') 40 | my_out_string<-my_out_string[-3] 41 | my_out_string<-my_out_string[-7] 42 | my_out_string[4]<-gsub(" (?= )", '-', my_out_string[4],perl = TRUE) 43 | my_out_string[4]<-gsub('.{5}$', '----\n', my_out_string[4]) 44 | my_out_string[3]<-gsub('.{3}$', '--\n', my_out_string[3]) 45 | my_out_string[5]<-gsub('.{3}$', '--\n', my_out_string[5]) 46 | 47 | structure(my_out_string, class = "banner") 48 | #print.banner(my_out_string) 49 | } 50 | 51 | #' @describeIn xxx_title1 the middle size title 52 | #' 53 | #' @export 54 | xxx_title0<-function(mystring=NULL){ 55 | if (is.null(mystring)) { 56 | mystring<-clipr::read_clip(allow_non_interactive = Sys.getenv("CLIPR_ALLOW", interactive())) 57 | } 58 | my_out_string<-my_own_banner(mystring, numLines = 2,upper=T, bandChar='~') 59 | my_out_string[5]<-gsub('.{5}$', '', my_out_string[5]) 60 | my_out_string[5]<-paste0(my_out_string[5],'----\n') 61 | structure(my_out_string, class = "banner") 62 | #print.banner(my_out_string) 63 | } 64 | 65 | #' @describeIn xxx_title1 the middle size title 66 | #' 67 | #' @export 68 | xxx_title2<-function(mystring=NULL){ 69 | if (is.null(mystring)) { 70 | mystring<-clipr::read_clip(allow_non_interactive = Sys.getenv("CLIPR_ALLOW", interactive())) 71 | } 72 | my_out_string<-my_own_banner(mystring,bandChar = '~', rightSideHashes = 2) 73 | my_out_string<-gsub('.{5}$', '', my_out_string) 74 | my_out_string[2]<-paste0(my_out_string[2],'~~~~\n') 75 | my_out_string[3]<-paste0(my_out_string[3],'----\n') 76 | my_out_string[4]<-paste0(my_out_string[4],'~~~~\n') 77 | structure(my_out_string, class = "banner") 78 | 79 | #print.banner2(my_out_string) 80 | } 81 | 82 | #' @describeIn xxx_title1 the smallest title 83 | #' 84 | #' @export 85 | xxx_title3<-function(mystring=NULL){ 86 | if (is.null(mystring)) { 87 | mystring<-clipr::read_clip(allow_non_interactive = Sys.getenv("CLIPR_ALLOW", interactive())) 88 | } 89 | mystring<-paste0('~ ',mystring,' ') 90 | my_out_string<-my_own_banner(mystring,bandChar = '~',snug=T,minHashes = 0, rightSideHashes = 0, centre = FALSE) 91 | my_out_string<-gsub('.{1}$', '', my_out_string) 92 | my_out_string[2]<-paste0(my_out_string[2],'~~~~\n') 93 | my_out_string[3]<-paste0(my_out_string[3],'----\n') 94 | my_out_string[4]<-paste0(my_out_string[4],'~~~~\n') 95 | structure(my_out_string, class = "banner") 96 | #print.banner2(my_out_string) 97 | } 98 | 99 | 100 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 | ## -- 102 | ##...................................ARTOFR.................................---- 103 | ## -- 104 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 105 | 106 | 107 | 108 | 109 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | ## XXX ---- 111 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 112 | 113 | 114 | ##~~~~~~~~~~~~ 115 | ## ~ XX ---- 116 | ##~~~~~~~~~~~~ 117 | -------------------------------------------------------------------------------- /R/xxx_box.R: -------------------------------------------------------------------------------- 1 | 2 | #' Convert sentences into a box of comments 3 | #' 4 | #' For user guide, please refer to \cr 5 | #' 6 | #' xxx_box is for paragraph, xxx_list is for bullet points or numbered list.\cr 7 | #' Number 1 in xxx_box1 and xxx_list1 imply style 1.\cr 8 | #' @param mystring A string, will be a line of comment. If missing, the function will try to grab texts from your clipboard. 9 | #' @param center A logical value: Do you want the text strings centred? 10 | #' (alternative: left justified) 11 | #' 12 | #' @return A character string vector returned invisibly, 13 | #' but automatically displayed in the console, the output will be saved into clipboard 14 | #' @export 15 | #' 16 | #' 17 | #' @examples 18 | #' # COMMON WORKFLOW OF THIS PACKAGE 19 | #' # 20 | #' # 1. To insert a box of comments etc with your own text 21 | #' # 2. copy the text you want from anywhere 22 | #' # 3. call xxx_box1() etc without arguments to grab text from clipboard 23 | #' # 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them 24 | #' # 5. paste it into your R script 25 | #' #............................................... 26 | #' # # SPECIFIC USAGE EXAMPLE: 27 | #' 28 | #' xxx_box('test sentence, test sentence, test sentence, test sentence',center = FALSE ) 29 | #' xxx_box1('test sentence, test sentence, test sentence, test sentence',center = FALSE ) 30 | #' xxx_box1('test sentence, test sentence, test sentence, test sentence',center = TRUE ) 31 | 32 | xxx_box<-function(mystring=NULL, center=FALSE){ 33 | if (is.null(mystring)) { 34 | mystring<-clipr::read_clip(allow_non_interactive = TRUE) 35 | 36 | } 37 | 38 | 39 | if (length(mystring)<1) { 40 | storage<-mystring 41 | storage2<-strwrap(storage,width=75) 42 | }else{ 43 | storage2='' 44 | storage = mystring[mystring != ""] #remove enpty row 45 | for (i in 1:length(storage)) { 46 | storage2[i]<-fold_it(storage[i],maxChar = 75) 47 | storage2[i]<-paste0('',storage2[i],'\n') 48 | } 49 | 50 | } 51 | 52 | 53 | my_own_banner(storage2, leftSideHashes = 1, rightSideHashes = 0, centre = center,numLines = 0) 54 | 55 | } 56 | 57 | 58 | #' @describeIn xxx_box Same as xxx_box but add border 59 | #' 60 | #' @export 61 | xxx_box1<-function(mystring=NULL, center=FALSE){ 62 | if (is.null(mystring)) { 63 | mystring<-clipr::read_clip(allow_non_interactive = TRUE) 64 | } 65 | 66 | 67 | if (length(mystring)<1) { 68 | storage<-mystring 69 | storage2<-strwrap(storage,width=75) 70 | }else{ 71 | storage2='' 72 | storage = mystring[mystring != ""] #remove enpty row 73 | for (i in 1:length(storage)) { 74 | storage2[i]<-fold_it(storage[i],maxChar=75) 75 | storage2[i]<-paste0('',storage2[i],'\n') 76 | } 77 | 78 | } 79 | storage3<-storage2 80 | storage3[2:(length(storage2)+1)]<-storage2 81 | storage3[1]<-' ' 82 | storage3[length(storage2)+2]<-''#storage 3 just to create empty space before and after paragraph 83 | my_own_banner(storage3, center=center, bandChar = ".",leftSideHashes=1,rightSideHashes=1) 84 | } 85 | 86 | 87 | #' @describeIn xxx_box Same as xxx_box but looks better for bullet points list or numbered list 88 | #' 89 | #' @export 90 | xxx_list<-function(mystring=NULL, center=FALSE){ 91 | if (is.null(mystring)) { 92 | mystring<-clipr::read_clip(allow_non_interactive = TRUE) 93 | 94 | } 95 | 96 | if (length(mystring)<1) { 97 | storage<-mystring 98 | storage2<-strwrap(storage,width=74) 99 | }else{ 100 | storage2='' 101 | storage = mystring 102 | 103 | # storage2<-stringr::str_wrap(storage,indent = 0,width=74,exdent =3) has the same effect as below 104 | for (i in 1:length(storage)) { 105 | storage2[i]<-fold_it(storage[i],maxChar=74,exdent =3) 106 | } 107 | 108 | } 109 | storage3<-storage2 110 | storage3[2:(length(storage2)+1)]<-storage2 111 | storage3[1]<-' ' 112 | storage3[length(storage2)+2]<-' '#storage 3 just to create empty space before and after paragraph 113 | my_own_banner(storage2, leftSideHashes = 1, rightSideHashes = 0, centre = center, 114 | minHashes = 0, numLines = 0) 115 | 116 | } 117 | 118 | #' @describeIn xxx_box Same as xxx_list but add border 119 | #' 120 | #' @export 121 | xxx_list1<-function(mystring=NULL, center=FALSE){ 122 | if (is.null(mystring)) { 123 | mystring<-clipr::read_clip(allow_non_interactive = TRUE) 124 | 125 | } 126 | 127 | if (length(mystring)<1) { 128 | storage<-mystring 129 | storage2<-strwrap(storage,width=74) 130 | }else{ 131 | storage2='' 132 | storage = mystring 133 | 134 | # storage2<-stringr::str_wrap(storage,indent = 0,width=74,exdent =3) has the same effect as below 135 | 136 | for (i in 1:length(storage)) { 137 | storage2[i]<-fold_it(storage[i],maxChar=74,exdent =3) 138 | } 139 | 140 | } 141 | storage3<-storage2 142 | storage3[2:(length(storage2)+1)]<-storage2 143 | storage3[1]<-' ' 144 | storage3[length(storage2)+2]<-' '#storage 3 just to create empty space before and after paragraph 145 | my_own_banner(storage3, center=center, bandChar = ".",leftSideHashes=1, rightSideHashes = 1) 146 | 147 | } 148 | 149 | #............................................................................... 150 | # . 151 | # I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 152 | # everyday and it makes my R script so neat. I used ARTofR everyday and it . 153 | # makes my R script so neat. . 154 | # . 155 | # I recommended this pacakge to all my families. . 156 | # . 157 | # Yes, even my grandmother like it! . 158 | # . 159 | #............................................................................... 160 | 161 | 162 | 163 | #............................................................................... 164 | # . 165 | # 1. I used ARTofR everyday . 166 | # 2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 167 | # everyday and it makes my R script so neat. . 168 | # 3. I recommended this pacakge to all my families. I recommended this . 169 | # pacakge to all my families. . 170 | # 4. Yes, even my grandmother like it! . 171 | # . 172 | #............................................................................... 173 | 174 | -------------------------------------------------------------------------------- /R/my_own_banner.R: -------------------------------------------------------------------------------- 1 | #' Core functions for comment making 2 | #' 3 | #' This is modified from \code{bannerCommenter::banner()}, the main modification is to extend the comment length (minHashes) to 80 4 | #' 5 | #' @param x A string, first line of the comment. If 6 | #' \code{""}, the zero-length string, only the top lines of the banner are made. 7 | #' If missing, in an interactive session the user will be prompted for the input 8 | #' strings, one per line, in the console. 9 | #' @param ... Zero or more additional strings as extra lines. Strings may contain 10 | #' newline characters resulting in further line breaks. 11 | #' @param emph A logical value: Do you want this to be an emphasised comment? 12 | #' @param snug A logical value: Do you want the decoration to hug the strings closely? 13 | #' @param upper A logical value: Do you want the strings converted to upper case? 14 | #' @param centre A logical value: Do you want the text strings centred? 15 | #' (alternative: left justified) 16 | #' @param leftSideHashes A positive integer: How many hashes go on the left side? 17 | #' @param rightSideHashes A non-negative integer: How many hashes go on the right side? 18 | #' @param minHashes A non-negative integer: What is the minimum number of hashes 19 | #' in the boundary lines? 20 | #' @param numLines A non-negative integer: How many lines of hashes above 21 | #' and below do you want? 22 | #' @param bandChar A single character. Used instead of # for all characters in 23 | #' the bands around the text, apart from the first character of every line. 24 | #' @param center Alternative spelling of \code{centre}. 25 | #' @param fold Logical: should the text be folded to ensure lines are not too long? 26 | #' @param maxChar Ingeter: maximum length allowed in any line if \code{fold} is \code{TRUE}. 27 | #' @import bannerCommenter 28 | #' 29 | #' @return A character string vector returned invisibly, 30 | #' but automatically displayed in the console 31 | #' @export 32 | #' @keywords internal 33 | #' @examples 34 | #' my_own_banner("This should appear clearly and stand out.", 35 | #' "The lines are left justified by default.") 36 | #' ##This is NOT recommended!!! 37 | #' ##This is NOT recommended!!! 38 | #' ##This is NOT recommended!!! 39 | #' ##pls use bannerCommenter::banner() 40 | my_own_banner<-function (x, ..., emph = FALSE, snug = FALSE, upper = emph, 41 | centre = !fold, leftSideHashes = 2 + emph, rightSideHashes = leftSideHashes, 42 | minHashes = (!snug) * (80 + 10 * emph), numLines = 1 + emph, 43 | bandChar = "#", center = centre, fold = FALSE, maxChar = 75) 44 | { 45 | if (missing(x)) { 46 | x <- if (interactive()) { 47 | paste(scan(what = "", sep = "\n", quiet = TRUE), 48 | collapse = "\n") 49 | } 50 | else "" 51 | } 52 | if (fold) { 53 | text <- gsub("\n", " ", paste(as.character(unlist(list(x, 54 | ...))), collapse = " ")) 55 | if (nchar(text) > maxChar) { 56 | txt <- character() 57 | repeat { 58 | if (nchar(text) <= maxChar) 59 | break 60 | pos <- gregexpr(" ", text)[[1]] 61 | if (any(pos < 0) || !any(pos <= maxChar)) 62 | break 63 | pos <- max(pos[pos <= maxChar]) 64 | txt <- c(txt, substring(text, 0, pos)) 65 | text <- substring(text, pos + 1, nchar(text)) 66 | } 67 | text <- paste(sub("^ +", "", sub(" +$", "", c(txt, 68 | text))), collapse = "\n") 69 | } 70 | } 71 | else { 72 | text <- paste(as.character(unlist(list(x, ...))), collapse = "\n") 73 | } 74 | text <- strsplit(text, "\n")[[1]] 75 | if (length(text) == 0) 76 | text <- "" 77 | nt <- length(text) 78 | kt <- seq_len(nt) 79 | n0 <- max(sapply(text, nchar)) 80 | hashes <- max(n0 + leftSideHashes + rightSideHashes + 2, 81 | minHashes) 82 | #hashes <- hashes + ((n0%%2) != (hashes%%2)) 83 | bandChar <- substring(paste0(as.character(bandChar), " "), 84 | 0, 1) 85 | line <- paste(c(rep("#", leftSideHashes), rep(bandChar, 86 | hashes - leftSideHashes), "\n"), collapse = "") 87 | leftHash <- paste(rep("#", leftSideHashes), collapse = "") 88 | rightHash <- paste(c(rep(bandChar, rightSideHashes), "\n"), 89 | collapse = "") 90 | if (nt == 1 && n0 == 0) 91 | return(structure(c("\n", rep(line, 1 + emph), "\n"), 92 | class = "banner")) 93 | if (missing(centre) & !missing(center)) 94 | centre <- center 95 | mid <- character(nt) 96 | for (k in kt) { 97 | blanks <- (hashes - leftSideHashes - rightSideHashes - 98 | nchar(text[[k]])) 99 | blanks1 <- ifelse(centre, round(blanks/2), 2) 100 | blanks2 <- blanks - blanks1 101 | left <- paste(c(leftHash, rep(" ", blanks1)), collapse = "") 102 | right <- paste(c(rep(" ", blanks2), rightHash), collapse = "") 103 | mid[k] <- paste(left, ifelse(upper, toupper(text[[k]]), 104 | text[[k]]), right, sep = "", collapse = "") 105 | } 106 | blanks <- rep(" ", hashes - leftSideHashes - rightSideHashes) 107 | gap <- paste(c(leftHash, blanks, rightHash), collapse = "") 108 | comment <- c("\n", rep(line, numLines), rep(gap, max(0, 109 | numLines - 1)), mid, rep(gap, max(0, numLines - 1)), 110 | rep(line, numLines), "\n") 111 | structure(comment, class = "banner") 112 | #invisible(comment) 113 | 114 | } 115 | 116 | 117 | #' @describeIn my_own_banner sub-function to fold sentence, don't use this in other circumstance 118 | #' @param x the string 119 | #' @param maxChar same as width in str_wrap 120 | #' @param exdent for xxx_list() 121 | #' @keywords internal 122 | #' @return 123 | 124 | 125 | fold_it<-function(x,maxChar,exdent = 0){ 126 | text <- gsub("\n", " ", paste(as.character(unlist(list(x))), collapse = " ")) 127 | if (nchar(text) > maxChar) { 128 | txt <- character() 129 | repeat { 130 | if (nchar(text) <= maxChar) 131 | break 132 | pos <- gregexpr(" ", text)[[1]] 133 | if (any(pos < 0) || !any(pos <= maxChar)) 134 | break 135 | pos <- max(pos[pos <= maxChar]) 136 | txt <- c(txt, substring(text, 0, pos)) 137 | text <- substring(text, pos + 1, nchar(text)) 138 | } 139 | exdent_blank=paste0(rep(" ",exdent),collapse = '') 140 | extend_part=paste0("\n",exdent_blank,collapse = '') 141 | text <- paste(sub("^ +", "", sub(" +$", "", c(txt, 142 | text))), collapse = extend_part ) 143 | } 144 | return(text) 145 | } 146 | 147 | 148 | # print.banner2 <- function(x, ...) { 149 | # y <- unlist(strsplit(x, "\n")) 150 | # #copy_to_clipboard(y, sep = "\n") 151 | # utils::writeClipboard(y,format=13) 152 | # cat(y, sep = "\n") 153 | # invisible(x) 154 | # } 155 | 156 | 157 | .onLoad <- function(libname, pkgname){ 158 | requireNamespace('bannerCommenter') 159 | } 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # Package to insert Title, Divider, and Block of Comments 5 | 6 | 7 | 8 | [![Travis build 9 | status](https://travis-ci.com/Hzhang-ouce/ARTofR.svg?branch=master)](https://app.travis-ci.com/github/Hzhang-ouce/ARTofR) 10 | [![R-CMD-check](https://github.com/Hzhang-ouce/ARTofR/workflows/R-CMD-check/badge.svg)](https://github.com/Hzhang-ouce/ARTofR/actions) 11 | 12 | 13 | Have you ever typed something like this in your R script as a section 14 | break: 15 | 16 | ``` r 17 | #.........................just a example......................... 18 | 19 | ``` 20 | 21 | ARTofR is designed to help you do this, by auto-inserting title, divider 22 | and block of comments, for example: 23 | 24 | `xxx_divider1('just a example')` will give you 25 | 26 | ``` r 27 | #.........................just a example......................... 28 | 29 | ``` 30 | 31 | `xxx_title2('another example')` will give you 32 | 33 | ``` r 34 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 35 | ## another example ---- 36 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 37 | 38 | ``` 39 | 40 | ARTofR is a wrapper of bannerCommenter::banner(), written with thanks to 41 | the author, Bill Venables 42 | 43 | ## Installation 44 | 45 | Install from CRAN: 46 | 47 | ``` r 48 | install.packages("ARTofR") 49 | ``` 50 | 51 | # User guide with Rstudio Addins 52 | 53 | > 1. Click `Addins` in your Rstudio top ribbon 54 | > 2. Choose `ARTofR user interface` 55 | > 3. Follow instruction in the app 56 | 57 | ![image](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/WeChatImage_20220306175401.png) 58 | ![image](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/Screenshot2022-03-06175714.png) 59 | 60 | # User guide for any R users 61 | 62 | ## Usage 1 - copy and paste 63 | 64 | > 1. type your text in any text editor 65 | > 2. copy your text 66 | > 3. call xxx_box() or xxx_box1() etc without arguments in R console 67 | > 4. NO NEED to copy again!!! 68 | > 5. paste into your R script 69 | 70 | For example: 71 | ![image](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/Screenshot138092.png?branch=master) 72 | 73 | ## Usage 2 - hand-typing 74 | 75 | ``` r 76 | xxx_title2('your title') 77 | 78 | 79 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 80 | ## your title ---- 81 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 82 | 83 | 84 | xxx_box1('your comments') 85 | 86 | 87 | #............................................................................... 88 | # . 89 | # your comments . 90 | # . 91 | #............................................................................... 92 | ``` 93 | 94 | # Functions and styles 95 | 96 | ## FUNCTION1: xxx_title 97 | 98 | **xxx_title() will automatically bring you a navigation panel** 99 | 100 | **but xxx_divider will not** 101 | 102 | For example: 103 | ![this](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/Screenshot13809.png?branch=master) 104 | 105 | ``` r 106 | library(ARTofR) 107 | xxx_title0('ARTofR') 108 | 109 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | ## ~~ 112 | ## ARTOFR ---- 113 | ## ~~ 114 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 115 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 116 | 117 | xxx_title1('ARTofR') 118 | 119 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 120 | ## -- 121 | ##...................................ARTOFR.................................---- 122 | ## -- 123 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 124 | 125 | xxx_title2('ARTofR') 126 | 127 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 128 | ## ARTofR ---- 129 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 130 | 131 | xxx_title3('ARTofR') 132 | 133 | ##~~~~~~~~~~~~~~~~ 134 | ## ~ ARTofR ---- 135 | ##~~~~~~~~~~~~~~~~ 136 | ``` 137 | 138 | ## FUNCTION2: xxx_divider 139 | 140 | You need to turn-off `auto-indent` in `options\code` of R studio, to 141 | keep the spaces before the line break 142 | 143 | ``` r 144 | library(ARTofR) 145 | xxx_divider1('') 146 | 147 | #................................................................ 148 | 149 | xxx_divider1('ARTofR') 150 | 151 | #.............................ARTofR............................. 152 | 153 | xxx_divider2('') 154 | 155 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 156 | 157 | xxx_divider2('ARTofR') 158 | 159 | # ARTofR ~~~ 160 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 161 | ``` 162 | 163 | ## FUNCTION3: xxx_box 164 | 165 | **Copy this paragraph:** 166 | 167 | ``` r 168 | 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. 169 | I recommended this pacakge to all my families. 170 | Yes, even my grandmother like it! 171 | ``` 172 | 173 | **Then in your R console do:** 174 | 175 | ``` r 176 | xxx_box() 177 | 178 | # I used ARTofR everyday and it makes my R script so neat. I used ARTofR 179 | # everyday and it makes my R script so neat. I used ARTofR everyday and it 180 | # makes my R script so neat. 181 | # 182 | # I recommended this pacakge to all my families. 183 | # 184 | # Yes, even my grandmother like it! 185 | 186 | 187 | xxx_box1() 188 | 189 | #............................................................................... 190 | # . 191 | # I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 192 | # everyday and it makes my R script so neat. I used ARTofR everyday and it . 193 | # makes my R script so neat. . 194 | # . 195 | # I recommended this pacakge to all my families. . 196 | # . 197 | # Yes, even my grandmother like it! . 198 | # . 199 | #............................................................................... 200 | 201 | 202 | xxx_box1(center = T) 203 | 204 | #............................................................................... 205 | # . 206 | # I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 207 | # everyday and it makes my R script so neat. I used ARTofR everyday and it . 208 | # makes my R script so neat. . 209 | # . 210 | # I recommended this pacakge to all my families. . 211 | # . 212 | # Yes, even my grandmother like it! . 213 | # . 214 | #............................................................................... 215 | ``` 216 | 217 | ## FUNCTION4: xxx_list 218 | 219 | **Copy this list:** 220 | 221 | ``` r 222 | 1. I used ARTofR everyday 223 | 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. 224 | 3. I recommended this pacakge to all my families. I recommended this pacakge to all my families. 225 | 4. Yes, even my grandmother like it! 226 | ``` 227 | 228 | Then in your R console: 229 | 230 | ``` r 231 | xxx_list() 232 | 233 | # 1. I used ARTofR everyday 234 | # 2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR 235 | # everyday and it makes my R script so neat. 236 | # 3. I recommended this pacakge to all my families. I recommended this 237 | # pacakge to all my families. 238 | # 4. Yes, even my grandmother like it! 239 | 240 | xxx_list1() 241 | 242 | #............................................................................... 243 | # . 244 | # 1. I used ARTofR everyday . 245 | # 2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 246 | # everyday and it makes my R script so neat. . 247 | # 3. I recommended this pacakge to all my families. I recommended this . 248 | # pacakge to all my families. . 249 | # 4. Yes, even my grandmother like it! . 250 | # . 251 | #............................................................................... 252 | ``` 253 | 254 | xxx_list1(center = T) is not recommended, use xxx_box(center=T) 255 | 256 | ## Tips and warnings: 257 | 258 | - Only Mac and windows were tested with this package. 259 | - xxx_divider2(’‘) and xxx_divider1(’’) will insert a break line in 260 | your text output 261 | - Once text was decorated, it would be difficult to restore. It is 262 | best to save your text in a plain-text file and copy from there, so 263 | that you can modify in the future. 264 | 265 | ## Motivation: 266 | 267 | There is a gratuitous advice in BannerCommenter help doc saying: ‘A 268 | potential danger of providing this simple facility is that some authors 269 | may be tempted to overdo their script decoration.’ 270 | 271 | These set of functions, being a wrapper of banner, was designed to 272 | 273 | 1. Achieve a balance between simplicity and complexity 274 | 2. Make use of Rstudio section tag and build a hierarchy 275 | 3. From clipboard to clipboard (e.g. call xxx_box() with no input, last 276 | texts in clipboard will be grabbed into the function) 277 | 4. It was called xxx so that it can be distinguished from any other R 278 | packages. 279 | 280 | ## Other packages 281 | 282 | Here are some other pacakages I found useful for R codes formatting: 283 | 284 | `strcode` `styler` `bannercommenter` 285 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | out.width = "100%" 13 | ) 14 | ``` 15 | 16 | # Package to insert Title, Divider, and Block of Comments 17 | 18 | 19 | [![Travis build status](https://travis-ci.com/Hzhang-ouce/ARTofR.svg?branch=master)](https://app.travis-ci.com/github/Hzhang-ouce/ARTofR) 20 | [![R-CMD-check](https://github.com/Hzhang-ouce/ARTofR/workflows/R-CMD-check/badge.svg)](https://github.com/Hzhang-ouce/ARTofR/actions) 21 | 22 | 23 | Have you ever typed something like this in your R script as a section break: 24 | 25 | ```r 26 | 27 | #.........................just a example......................... 28 | 29 | 30 | ``` 31 | 32 | ARTofR is designed to help you do this, by auto-inserting title, divider and block of comments, for example: 33 | 34 | `xxx_divider1('just a example')` will give you 35 | 36 | ```r 37 | 38 | #.........................just a example......................... 39 | 40 | 41 | ``` 42 | 43 | `xxx_title2('another example')` will give you 44 | 45 | ```r 46 | 47 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 48 | ## another example ---- 49 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 50 | 51 | 52 | ``` 53 | 54 | ARTofR is a wrapper of bannerCommenter::banner(), written with thanks to the author, Bill Venables 55 | 56 | ## Installation 57 | 58 | Install from CRAN: 59 | 60 | ```r 61 | install.packages("ARTofR") 62 | 63 | ``` 64 | 65 | # User guide with Rstudio Addins 66 | 67 | > 68 | 1. Click `Addins` in your Rstudio top ribbon 69 | 2. Choose `ARTofR user interface` 70 | 3. Follow instruction in the app 71 | 72 | ![image](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/WeChatImage_20220306175401.png) 73 | ![image](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/Screenshot2022-03-06175714.png) 74 | 75 | # User guide for any R users 76 | 77 | ## Usage 1 - copy and paste 78 | 79 | > 80 | 1. type your text in any text editor 81 | 2. copy your text 82 | 3. call xxx_box() or xxx_box1() etc without arguments in R console 83 | 4. NO NEED to copy again!!! 84 | 5. paste into your R script 85 | 86 | For example: ![image](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/Screenshot138092.png?branch=master) 87 | 88 | ## Usage 2 - hand-typing 89 | 90 | ```{r, include = T,eval=FALSE} 91 | xxx_title2('your title') 92 | 93 | 94 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 95 | ## your title ---- 96 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 97 | 98 | 99 | xxx_box1('your comments') 100 | 101 | 102 | #............................................................................... 103 | # . 104 | # your comments . 105 | # . 106 | #............................................................................... 107 | 108 | ``` 109 | 110 | # Functions and styles 111 | 112 | ## FUNCTION1: xxx_title 113 | 114 | **xxx_title() will automatically bring you a navigation panel** 115 | 116 | **but xxx_divider will not** 117 | 118 | For example: ![this](https://raw.githubusercontent.com/Hzhang-ouce/ARTofR/master/Screenshot13809.png?branch=master) 119 | 120 | 121 | ```{r, include = T,eval=FALSE} 122 | library(ARTofR) 123 | xxx_title0('ARTofR') 124 | 125 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 126 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127 | ## ~~ 128 | ## ARTOFR ---- 129 | ## ~~ 130 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 131 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 132 | 133 | xxx_title1('ARTofR') 134 | 135 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 136 | ## -- 137 | ##...................................ARTOFR.................................---- 138 | ## -- 139 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 140 | 141 | xxx_title2('ARTofR') 142 | 143 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 144 | ## ARTofR ---- 145 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 146 | 147 | xxx_title3('ARTofR') 148 | 149 | ##~~~~~~~~~~~~~~~~ 150 | ## ~ ARTofR ---- 151 | ##~~~~~~~~~~~~~~~~ 152 | 153 | ``` 154 | 155 | ## FUNCTION2: xxx_divider 156 | 157 | You need to turn-off `auto-indent` in `options\code` of R studio, to keep the spaces before the line break 158 | 159 | ```{r, include = T,eval=FALSE} 160 | library(ARTofR) 161 | xxx_divider1('') 162 | 163 | #................................................................ 164 | 165 | xxx_divider1('ARTofR') 166 | 167 | #.............................ARTofR............................. 168 | 169 | xxx_divider2('') 170 | 171 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 172 | 173 | xxx_divider2('ARTofR') 174 | 175 | # ARTofR ~~~ 176 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 177 | 178 | ``` 179 | 180 | ## FUNCTION3: xxx_box 181 | 182 | 183 | **Copy this paragraph:** 184 | 185 | ```{r, include = T,eval=FALSE} 186 | 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. 187 | I recommended this pacakge to all my families. 188 | Yes, even my grandmother like it! 189 | ``` 190 | 191 | **Then in your R console do:** 192 | 193 | ```{r, include = T,eval=FALSE} 194 | 195 | xxx_box() 196 | 197 | # I used ARTofR everyday and it makes my R script so neat. I used ARTofR 198 | # everyday and it makes my R script so neat. I used ARTofR everyday and it 199 | # makes my R script so neat. 200 | # 201 | # I recommended this pacakge to all my families. 202 | # 203 | # Yes, even my grandmother like it! 204 | 205 | 206 | xxx_box1() 207 | 208 | #............................................................................... 209 | # . 210 | # I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 211 | # everyday and it makes my R script so neat. I used ARTofR everyday and it . 212 | # makes my R script so neat. . 213 | # . 214 | # I recommended this pacakge to all my families. . 215 | # . 216 | # Yes, even my grandmother like it! . 217 | # . 218 | #............................................................................... 219 | 220 | 221 | xxx_box1(center = T) 222 | 223 | #............................................................................... 224 | # . 225 | # I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 226 | # everyday and it makes my R script so neat. I used ARTofR everyday and it . 227 | # makes my R script so neat. . 228 | # . 229 | # I recommended this pacakge to all my families. . 230 | # . 231 | # Yes, even my grandmother like it! . 232 | # . 233 | #............................................................................... 234 | 235 | 236 | ``` 237 | 238 | ## FUNCTION4: xxx_list 239 | 240 | **Copy this list:** 241 | 242 | ```{r, include = T,eval=FALSE} 243 | 1. I used ARTofR everyday 244 | 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. 245 | 3. I recommended this pacakge to all my families. I recommended this pacakge to all my families. 246 | 4. Yes, even my grandmother like it! 247 | ``` 248 | 249 | Then in your R console: 250 | 251 | ```{r, include = T,eval=FALSE} 252 | xxx_list() 253 | 254 | # 1. I used ARTofR everyday 255 | # 2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR 256 | # everyday and it makes my R script so neat. 257 | # 3. I recommended this pacakge to all my families. I recommended this 258 | # pacakge to all my families. 259 | # 4. Yes, even my grandmother like it! 260 | 261 | xxx_list1() 262 | 263 | #............................................................................... 264 | # . 265 | # 1. I used ARTofR everyday . 266 | # 2. I used ARTofR everyday and it makes my R script so neat. I used ARTofR . 267 | # everyday and it makes my R script so neat. . 268 | # 3. I recommended this pacakge to all my families. I recommended this . 269 | # pacakge to all my families. . 270 | # 4. Yes, even my grandmother like it! . 271 | # . 272 | #............................................................................... 273 | 274 | ``` 275 | 276 | xxx_list1(center = T) is not recommended, use xxx_box(center=T) 277 | 278 | ## Tips and warnings: 279 | 280 | * Only Mac and windows were tested with this package. 281 | * xxx_divider2('') and xxx_divider1('') will insert a break line in your text output 282 | * 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. 283 | 284 | ## Motivation: 285 | 286 | There is a gratuitous advice in BannerCommenter help doc saying: 287 | ‘A potential danger of providing this simple facility is that some authors may be tempted to overdo their script decoration.’ 288 | 289 | These set of functions, being a wrapper of banner, was designed to 290 | 291 | 1. Achieve a balance between simplicity and complexity 292 | 2. Make use of Rstudio section tag and build a hierarchy 293 | 3. From clipboard to clipboard (e.g. call xxx_box() with no input, last texts in clipboard will be grabbed into the function) 294 | 4. It was called xxx so that it can be distinguished from any other R packages. 295 | 296 | ## Other packages 297 | 298 | Here are some other pacakages I found useful for R codes formatting: 299 | 300 | `strcode` 301 | `styler` 302 | `bannercommenter` 303 | --------------------------------------------------------------------------------