• Stars
    star
    140
  • Rank 252,048 (Top 6 %)
  • Language
    R
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Prefix function with their namespace & other development tools

prefixer::

Prefix function with their namespace and other tools for writing functions / packages

Travis-CI Build Status Project Status: Active-The project has reached a stable, usable state and is being actively developed. Lifecycle: stable R build status

Overview

It can be useful to prefix function in a script to prevent use of the wrong one, e.g. stats::filter vs dplyr::filter or plyr::summarise vs dplyr::summarise. This package provide a Shiny gadget to interactively add prefix to function in a script, if a function exist in several packages, you can choose the one you want use.

If you're in a package, you can generate @importFrom tag from function definition and after remove prefix if needed.

Installation :

# with remotes
remotes::install_github("dreamRs/prefixer")

⚠️ functions of this package will modify your scripts

prefixer:: gadget

You can launch the addin via RStudio's Addins menu. Interface looks like this :

fread_dir <- function(path, pattern = "\\.csv$") {
  paths <- list.files(path = path, pattern = pattern, full.names = TRUE)
  files <- lapply(paths, fread)
  files <- setNames(files, paths)
  rbindlist(l = files, idcol = "path")
}

Becomes =>

fread_dir <- function(path, pattern = "\\.csv$") {
  paths <- list.files(path = path, pattern = pattern, full.names = TRUE)
  files <- lapply(paths, data.table::fread)
  files <- stats::setNames(files, paths)
  data.table::rbindlist(l = files, idcol = "path")
}

@importFrom

From prefixed functions, you can generate roxygen @importFrom tag via addin @importFrom.

Or manually with import_from(fun = fread_dir):

#' @importFrom data.table fread rbindlist
#' @importFrom stats setNames
fread_dir <- function(path, pattern = "\\.csv$") {
  paths <- list.files(path = path, pattern = pattern, full.names = TRUE)
  files <- lapply(paths, data.table::fread)
  files <- stats::setNames(files, paths)
  data.table::rbindlist(l = files, idcol = "path")
}

Unprefix

After generated @importFrom tags, you can if you want remove prefix before your functions via addin Unprefix :

#' @importFrom data.table fread rbindlist
#' @importFrom stats setNames
fread_dir <- function(path, pattern = "\\.csv$") {
  paths <- list.files(path = path, pattern = pattern, full.names = TRUE)
  files <- lapply(paths, fread)
  files <- setNames(files, paths)
  rbindlist(l = files, idcol = "path")
}

Roxygen comments

Addin Roxygen comment allow to comment selected line with #'.

Not-ASCII

Addin Not-ASCII escape all not-ASCII characters between quotes to Unicode, to avoid warning in R CMD check :

frenchFileInput <- function(inputId) {
  fileInput(
    inputId = inputId,
    label = "Sélectionner un fichier :",
    buttonLabel = "Parcourir...",
    placeholder = "Aucun fichier sélectionné"
  )
}

becomes =>

frenchFileInput <- function(inputId) {
  fileInput(
    inputId = inputId,
    label = "S\u00e9lectionner un fichier :",
    buttonLabel = "Parcourir...",
    placeholder = "Aucun fichier s\u00e9lectionn\u00e9"
  )
}

Show Non-ASCII files

Show files containing Non-ASCII characters in RStudio markers tabs. This function is similar to tools::showNonASCIIfile.

show_nonascii_file()

Check Rd files

Check if your Rd files (documentation) contains examples and return value:

check_Rd_examples()
# 1 Rd file(s) with no examples. 
#  - unprefix.Rd 

check_Rd_value()
# 2 Rd file(s) with no value. 
#  - prefixer.Rd 
#  - unprefix.Rd 

Count calls

Get functions used in scripts and where they come from, for example functions used in this package:

count_calls("R/")
#                      call  n                  package
# 1                    tags 36                htmltools
# 2              rstudioapi 15                     <NA>
# 3         str_replace_all 15                  stringr
# 4                     div  9                htmltools
# 5                       b  8                     <NA>
# 6            observeEvent  8                    shiny
# 7                     pre  6                htmltools
# 8           set_selection  6                 prefixer
# 9  getSourceEditorContext  5               rstudioapi
# 10             insertText  5               rstudioapi
# ...

More Repositories

1

esquisse

RStudio add-in to make plots interactively with ggplot2
R
1,719
star
2

shinyWidgets

shinyWidgets : Extend widgets available in shiny
R
794
star
3

fresh

Fresh shiny themes
SCSS
221
star
4

billboarder

📊 R Htmlwidget for billboard.js
R
172
star
5

shinybusy

Minimal busy indicator for Shiny apps
R
137
star
6

apexcharter

📊 R Htmlwidget for ApexCharts.js
R
135
star
7

datamods

Shiny modules to import data into an application or addin
R
127
star
8

gfonts

🔤 Offline Google Fonts for rmarkdown and shiny
R
112
star
9

shinyapps

Some Shiny applications
R
99
star
10

shinylogs

Logs for Shiny apps
R
96
star
11

colorscale

Create a color scale from a single color
R
80
star
12

shufflecards

✨ Create magical grid layouts in Shiny & Markdown
R
80
star
13

toastui

R htmlwidgets for ToastUI libraries: grid, calendar and chart
R
75
star
14

r2d3maps

r2d3 experiment to draw maps in D3
R
73
star
15

tuicalendr

📆 R htmlwidget for tui-calendar
R
54
star
16

topogram

R htmlwidget for cartogram-chart
R
51
star
17

shinypop

Collection of notifications, confirm dialogs and alerts for 'Shiny' applications
JavaScript
50
star
18

addinit

Initialize & structure an 'RStudio' Project
R
50
star
19

viewxl

'RStudio' addin to open data.frame(s) in Excel
R
47
star
20

wired

Wired elements in Shiny
JavaScript
47
star
21

shinytreeview

Hierarchical tree input for Shiny apps
R
40
star
22

memory-hex

Hex Memory Game in Shiny
R
33
star
23

sqlquery

Htmlwidget to write SQL queries
JavaScript
31
star
24

capture

Take screenshots in Shiny apps
JavaScript
29
star
25

particlesjs

Particles.js for Shiny apps & rmarkdown
R
26
star
26

timelineschart

Htmlwidget for timelines-chart
R
26
star
27

jstools

Tools to work with JavaScript and CSS files
JavaScript
24
star
28

flexpivot

Simple frequency table
R
23
star
29

weather

Weather icons in ggplot2, shiny and rmarkdown
SCSS
20
star
30

phosphoricons

Phosphor Icons for R
R
19
star
31

where

📍 Cities database and a game!
R
16
star
32

d3.format

R interface for d3.format
R
16
star
33

shinyvs

Virtual Select widget for shiny apps
R
16
star
34

resizer

Simulate screen resolution for Shiny apps
R
15
star
35

tuichartr

📊 R htmlwidget for tui-chart
R
14
star
36

grillade

Grid sytem for shiny apps or rmarkdown and to create htmlwidgets matrix
R
13
star
37

rte.data

Access data from RTE API
R
10
star
38

tweets-transports

Analyse des tweets des lignes de transport parisien
R
9
star
39

bar

R Htmlwidget for proportions-chart JavaScript library
JavaScript
9
star
40

shinywb

Interface to WinBox JavaScript library to use in shiny applications
R
8
star
41

talks

💬 Slides for dreamRs talks
5
star
42

france-power-grid

French housing connected to the electricity grid
R
4
star
43

luciole

Luciole font for R. a new typeface developed explicitly for visually impaired people
R
2
star
44

nlpr.fr

Client for 'NLP.js' for Natural Language Operations in French
R
2
star
45

uPlot-r

R htmlwidget for µPlot.js
R
1
star
46

rr2018addins

Exemples d'add-ins RStudio pour les rencontres R 2018
R
1
star