add_row

0th

Percentile

Add rows to a data frame

This is a convenient way to add one or more rows of data to an existing data frame. See tribble() for an easy way to create an complete data frame row-by-row.

Usage
add_row(.data, ..., .before = NULL, .after = NULL)
Arguments
.data

Data frame to append to.

...

Name-value pairs. If you don't supply the name of a variable, it'll be given the value NA.

.before, .after

One-based row index where to add the new rows, default: after last row

See Also

Other addition: add_column

Aliases
  • add_row
Examples
# NOT RUN {
# add_row ---------------------------------
df <- tibble(x = 1:3, y = 3:1)

add_row(df, x = 4, y = 0)

# You can specify where to add the new rows
add_row(df, x = 4, y = 0, .before = 2)

# You can supply vectors, to add multiple rows (this isn't
# recommended because it's a bit hard to read)
add_row(df, x = 4:5, y = 0:-1)

# Absent variables get missing values
add_row(df, x = 4)

# You can't create new variables
# }
# NOT RUN {
add_row(df, z = 10)
# }
Documentation reproduced from package tibble, version 1.3.4, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.