# Create a separate block
new_separate_block()
if (interactive()) {
# Basic usage - separate full name into first and last
library(blockr.core)
people_data <- data.frame(
full_name = c("John Doe", "Jane Smith", "Bob Johnson"),
age = c(30, 25, 35)
)
serve(
new_separate_block(
col = "full_name",
into = c("first_name", "last_name"),
sep = " "
),
data = list(data = people_data)
)
# Separate date components
date_data <- data.frame(
date_string = c("2024-01-15", "2024-02-20", "2024-03-25")
)
serve(
new_separate_block(
col = "date_string",
into = c("year", "month", "day"),
sep = "-",
convert = TRUE
),
data = list(data = date_data)
)
# Using regex separator
mixed_data <- data.frame(
mixed_col = c("a-b", "c_d", "e.f")
)
serve(
new_separate_block(
col = "mixed_col",
into = c("col1", "col2"),
sep = "[-_.]"
),
data = list(data = mixed_data)
)
}
Run the code above in your browser using DataLab