This is a dplyr-dependent preprocessing function

nfkc_all(
  .data,
  remove_space_colnames = FALSE,
  remove_space_contents = FALSE,
  coln_spc = "[:blank:]",
  cont_spc = "[:blank:]"
)

Arguments

.data

data.frame-like object (tibble, data.table, etc.)

remove_space_colnames

If TRUE, remove all white spaces from all column names. Default: FALSE.

remove_space_contents

If TRUE, remove all white spaces from all contents. Default: FALSE.

coln_spc

Space character to be removed in colnames.

cont_spc

Space character to be removed in contents.

Value

object of the same class as .data

Examples

 # data.frame
 df <- data.frame(`列1(トン)` = 1, `列2 (kg) ` = 2)
 nfkc_all(df)
#>   列1.トン. 列2..kg..
#> 1         1         2

 # data.table
 require(data.table)
#> Loading required package: data.table
#> data.table 1.14.8 using 1 threads (see ?getDTthreads).  Latest news: r-datatable.com
#> **********
#> This installation of data.table has not detected OpenMP support. It should still work but in single-threaded mode.
#> This is a Mac. Please read https://mac.r-project.org/openmp/. Please engage with Apple and ask them for support. Check r-datatable.com for updates, and our Mac instructions here: https://github.com/Rdatatable/data.table/wiki/Installation. After several years of many reports of installation problems on Mac, it's time to gingerly point out that there have been no similar problems on Windows or Linux.
#> **********
 dt <- data.table(`列1(トン)` = 1.1, `列2 (kg) ` = 2.1)
 nfkc_all(dt)
#>    列1(トン) 列2 (kg) 
#> 1:       1.1       2.1

 # tibble
 require(tibble)
#> Loading required package: tibble
 tbl <- tibble(`列1(トン)` = "1.2\r\nトン", `列2 (kg) ` = " 2.2\n kg")
 nfkc_all(tbl)
#> # A tibble: 1 × 2
#>   `列1(トン)`   `列2 (kg) `
#>   <chr>         <chr>      
#> 1 "1.2\r\nトン" " 2.2\n kg"
 # remove white-spaces (blanks) from all column names
 nfkc_all(tbl, remove_space_colnames = TRUE)
#> # A tibble: 1 × 2
#>   `列1(トン)`   `列2(kg)`  
#>   <chr>         <chr>      
#> 1 "1.2\r\nトン" " 2.2\n kg"
 # remove white-spaces (blanks) from all contents
 nfkc_all(tbl, remove_space_contents = TRUE)
#> # A tibble: 1 × 2
#>   `列1(トン)`   `列2 (kg) `
#>   <chr>         <chr>      
#> 1 "1.2\r\nトン" "2.2\nkg"  
 # remove all white-spaces (blanks) from .data
 nfkc_all(tbl, remove_space_colnames = TRUE, remove_space_contents = TRUE)
#> # A tibble: 1 × 2
#>   `列1(トン)`   `列2(kg)`
#>   <chr>         <chr>    
#> 1 "1.2\r\nトン" "2.2\nkg"

 # remove all spaces (including new line characters) from all contents
 nfkc_all(tbl, remove_space_contents = TRUE, cont_spc = "[:space:]")
#> # A tibble: 1 × 2
#>   `列1(トン)` `列2 (kg) `
#>   <chr>       <chr>      
#> 1 1.2トン     2.2kg