0

For reasons not relevant, let's assume I want to use rbind like so:

df.new = rbind(df.old, c(1, 2, 1, 1)

BUT, the issue is that df.new has 5 columns, not 4. I want to leave the last field blank by design. Is this possible using rbind?

Joseph Erickson
  • 938
  • 3
  • 8
  • 24
  • `rbindlist` from `data.table` package has an arg `fill` for such cases - would automatically fill out `NA`s for you. – davidski Jan 11 '17 at 22:12

1 Answers1

1

Use NA as a placeholder in the columns you want to leave blank:

df.new = rbind(df.old, c(1, 2, 1, 1, NA))
Mark Timms
  • 596
  • 3
  • 4