Creating an empty dataframe in R is as simple as setting the dataframe column specifications.
df <- data.frame( id = integer(), first_name = character(), last_name = character(), salary = double() )
Using str()
or dplyr::glimpse()
indicates an empty dataframe with the specified column types, which you can now bind rows to etc.
str(df) 'data.frame': 0 obs. of 4 variables: $ id : int $ first_name: chr $ last_name : chr $ salary : num
df %>% dplyr::glimpse() Rows: 0 Columns: 4 $ id$ first_name $ last_name $ salary