Install and load package “tibble”.
df <- tibble(x = 1:3, y = 3:1)
The row is added in the end of the data frame.
df %>% add_row(x = 4, y = 0)
## # A tibble: 4 x 2
## x y
## <dbl> <dbl>
## 1 1 3
## 2 2 2
## 3 3 1
## 4 4 0
df %>% add_row(x = 4, y = 0, .before = 2)
## # A tibble: 4 x 2
## x y
## <dbl> <dbl>
## 1 1 3
## 2 4 0
## 3 2 2
## 4 3 1
df %>% add_row(x = 4:5, y = 0:-1)
## # A tibble: 5 x 2
## x y
## <int> <int>
## 1 1 3
## 2 2 2
## 3 3 1
## 4 4 0
## 5 5 -1
df %>% add_row(x = 4)
## # A tibble: 4 x 2
## x y
## <dbl> <int>
## 1 1 3
## 2 2 2
## 3 3 1
## 4 4 NA