I have a data.frame
that looks like this.
df <-
tibble::tribble(
~name, ~age, ~birthday, ~address, ~favorite_fruit,
'josh', '1998-04-14', '1 main st', 'banana', NA,
'jason', '2000-09-01', '2 front st', 'apple', NA,
'nate', '1992-dec-25', '3 oak st', 'blueberry', NA
)
df
#> # A tibble: 3 x 5
#> name age birthday address favorite_fruit
#> <chr> <chr> <chr> <chr> <lgl>
#> 1 josh 1998-04-14 1 main st banana NA
#> 2 jason 2000-09-01 2 front st apple NA
#> 3 nate 1992-dec-25 3 oak st blueberry NA
As you might notice, age data was not collected (ignoring that I could calculate it from birthday
). Therefore, all values after the name
column are incorrectly shifted to the left by one column. My ideal output would be NA
s in the age
column and the correct values in all other columns. How can I achieve this? If possible, a tidyverse solution is preferred.