1

After transposing my data I am right now at this stage:

Alex Aro Billie Piper Chris Fe Daron Chlim Erik Fuc (3000 more names)

Only headers, but no data inside. Now I want to populate the empty dataframe like this:

Alex Aro Billie Piper Chris Fe Daron Chlim Erik Fuc (3000 more names)
NA NA NA NA NA NA
NA NA NA NA NA NA
NA NA NA NA NA NA
NA NA NA NA NA NA
NA NA NA NA NA NA
NA NA NA NA NA NA
(18 000 rows) NA NA NA NA NA

It does not matter if I have zeros or NA in the end. As you can see lots of rows and columns, so code is only useful if I do not have to type every row and column by myself. Thanks in advance!

  • This question has been aswered [here](https://stackoverflow.com/questions/48833807/initialize-an-empty-tibble-with-column-names-and-0-rows/57734431#57734431). – Daniel Jul 06 '21 at 11:55

1 Answers1

1

You subset the empty dataframe. If the dataframe with headers is called df to create 18000 rows with NA values you can do -

out <- df[1:18000, ]
rownames(out) <- NULL
out
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213