I have a column time_bin
that is based on cumulative radiocarbon dates. However I need to fill the gaps in the time_bin
sequence. In the example data below this means I need 2700, and 3100 added in. This will be applied to a lot of different data sets with different gaps so needs to be automated. It will have to expand this size of the dataframe, its fine if the values in the other columns are just NA for now as I think I know how to populate them with what I need once they're created.
The time_bin
column is created by using mutate
along with ceiling
as shown below, so maybe it can be changed at this point, rather than later.
I can create the column I need,called seq
below, but I'm not sure how to force it into a dataframe.
If there's a way this can be done with a tidyverse aproach rather than vectored as I have done it that would be great too.
So far I have:
data<- structure(list(cumulative.time = c(2458.09948930625, 2580.22242330625,
2707.31373980624, 2839.71214840625, 2977.77505230625, 3121.87854830625
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
data <- data%>% mutate(time_bin=ceiling(cumulative.time/100)*100)
max <- max(data$time_bin, na.rm = TRUE)
min <- min(data$time_bin, na.rm = TRUE)
seq <- seq(from = min, to = max, by = 100)
Thanks people!