(Beginner) Cosinor function - how to load time variable

Any problem in R can be approached with advantage using the basic idea of school algebra: f(x) = y where the three objects are

x, called an argument, which is what is at hand, in this case a vector of strings representing HH:MM:SS

y the object that is desired

f a function, which may be composed to transform x to y.

There are regression methods meant to work with time series specifically that be considered if the time data are more variable. The Time variable might, in this case of ordinary least square regression be treated as a categorical variable since it seems, a priori, unlikely that Activity varies continuously with the passage of time. However, the conversion below assumes that seconds is the appropriate measure.

# LIBRARIES
suppressPackageStartupMessages({
  library(dplyr)
  library(purrr)
  library(stringr)
  })

# FUNCTIONS

mk_secs <- function(x) x[1]*3600 + x[2] * 60 + x[3] * 1

# DATA

first_time <- rep("10:10:00",10)
second_time <- rep("10:11:00",10)
the_times <- c(first_time,second_time)

# MAIN

str_split(the_times,":") %>% 
  map(., as.numeric) %>%
  map(., mk_secs) %>%
  unlist(.)
#>  [1] 36600 36600 36600 36600 36600 36600 36600 36600 36600 36600 36660 36660
#> [13] 36660 36660 36660 36660 36660 36660 36660 36660

Created on 2020-10-23 by the reprex package (v0.3.0.9001)