When using xtable()
to print a data frame into HTML email body the output changes to numeric instead of the original format on the data frame which is set as.hms()
The original observation is numeric: 79
and the below code converts the average to as.hms()
format 00:01:19
Avg_Answer_Time <- transport %>%
filter(Call_Type == "Inbound customer") %>%
summarise(as.hms(round(mean(TimeInQueue))))
And then run the below code for the data frame to HTML the output goes back to numeric on the email: 79
InboundSummary <- print(xtable(Inbound_Summary, digits = 0), type="html", print.results=FALSE, )
InboundBody <- paste0("<html>", InboundSummary, "</html>")
Is there any way to print as the original format (00:01:19) or have it to print the output as time format preferably minutes and seconds?
Example:
library(xtable)
library(hms)
seconds <- c(79,50,37)
queue_secs <- as_hms(round(mean(seconds)))
x <- data.frame(queue_secs)
time_in_secs <- print(xtable(x), type="html", print.results=FALSE )
time_in_secs_body <- paste0("<html>", time_in_secs,"<html>")