0

I have a data frame where the first column is numbered from 1 - 95. However, some of these values are missing, so I want to add an empty row where those missing values are. For example, my numbers are 1, 2, 4, 5, 6, 8 in column A.

I want to:

  1. Find where all of the empty values are
  2. Add an empty row where these empty values are
  3. After adding an empty row, fill these empty cells in column A with the correct number (i.e. adding in row "3" and row "8")

Is there a function that can help me do this?

Thank you.

  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Perhaps the `tidyr::complete` function is what you want. – MrFlick Jun 19 '19 at 19:40

1 Answers1

0

Assuming the name of your index column is A.

dat = data.frame('A' = 1:95)

dat_new = dat %>% left_join(your_set,by='A')
spazznolo
  • 747
  • 3
  • 9