fill_blank: Fill empty strings ("") in character column of data.frame...

Description Usage Arguments Value Examples

View source: R/fill_blank.R

Description

fill_blank fills any empty "" strings in a data.frame character column with the corresponding values from another character, numeric, or boolean column in the same data.frame.

Usage

1
fill_blank(df, blank_col, fill_col)

Arguments

df

data.frame

blank_col

quoted name of character column in df: contains empty strings

fill_col

quoted name of character, numeric, or boolean column in df: contains values to replace empty strings

Value

df with empty strings in a specific character column filled with strings from another column.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# make data.frame with blanks
# columns must be data type = character
df <- data.frame(name1 = c("Bob", "Jane", "Henry"),
                 name2 = c("Mary", "", ""),
                 num1 = c(1, 2, 3),
                 num2 = c("", "", 7),
                 stringsAsFactors = FALSE)

# fill blanks in names2
df <- fill_blank(df, "name2", "name1")

csdaw/csdata documentation built on April 23, 2020, 10:48 p.m.