ronencozen
ronencozen

Reputation: 2201

R - How to add a timestamp column to a data frame definition

I am wondering is it possible to add a timestamp also known as DateTime column to a data frame definition (i.e. append the column post creation); if not what are the alternatives?

Note: timestamp column has not be defined correctly; therefore this code is not reproducible.

results <- tibble(timestamp = DateTime?, 
                  comment = character(), 
                  model = character(), 
                  RMSE = double())

Upvotes: 3

Views: 2215

Answers (1)

M--
M--

Reputation: 28825

I think this addresses your question:

library(tibble)
results <- tibble( timestamp = as.POSIXct(character()),
                  comment = character(), 
                  model = character(), 
                  RMSE = double())

     results
#    # A tibble: 0 x 4
#    # ... with 4 variables: timestamp <dttm>, comment <chr>,
#    #   model <chr>, RMSE <dbl>

Upvotes: 2

Related Questions