Learn R Programming

tibble (version 1.0)

add_row: Add a row to a data frame

Description

This is a convenient way to add a single row of data to an existing data frame. See frame_data for an easy way to create an complete data frame row-by-row.

Usage

add_row(.data, ...)

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.

Examples

Run this code
# add_row ---------------------------------
df <- data_frame(x = 1:3, y = 3:1)

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

# 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
add_row(df, z = 10)

Run the code above in your browser using DataLab