3
df <-data.frame(x=1:2,y=5:6)
row <- list(x=10,y=20)
add_row(df,row)

Error: New rows can't add columns. x Can't find column row in .data. Run rlang::last_error() to see where the error occurred.

but

add_row(df,x=10,y=20)
   x  y
1  1  5
2  2  6
3 10 20

works. Please help me add named list into df?

vishal
  • 855
  • 1
  • 8
  • 16

1 Answers1

2

Using rbind as suggested by @DanY is an easy solution, to use add_row you can change row to tibble or data.frame :

library(tibble)

df <-data.frame(x=1:2,y=5:6)
row <- tibble(x=10,y=20)
add_row(df, row)

#   x  y
#1  1  5
#2  2  6
#3 10 20
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213