Learn R Programming

blockr.dplyr (version 0.1.0)

new_rename_block: Rename block constructor

Description

This block allows renaming columns in a data frame using the visual interface (see dplyr::rename()). Changes are applied after clicking the submit button. Uses new_name = old_name syntax where new_name is what you want to call the column and old_name is the current column name.

Usage

new_rename_block(renames = list(new_col = character()), ...)

Value

A block object for rename operations

Arguments

renames

Named list or vector of renames in new_name = old_name format

...

Additional arguments forwarded to blockr.core::new_block()

See Also

blockr.core::new_transform_block()

Examples

Run this code
# Create a rename block
new_rename_block(list(miles_per_gallon = "mpg", cylinders = "cyl"))

if (interactive()) {
  # Basic usage with mtcars dataset
  library(blockr.core)
  serve(new_rename_block(), data = list(data = mtcars))

  # With predefined renames
  serve(
    new_rename_block(list(miles_per_gallon = "mpg", cylinders = "cyl")),
    data = list(data = mtcars)
  )

  # Connected blocks example
  serve(
    new_board(
      blocks = list(
        a = new_dataset_block(),
        b = new_rename_block(list(horsepower = "hp"))
      ),
      links = links(
        from = c("a"),
        to = c("b")
      )
    )
  )
}

Run the code above in your browser using DataLab