I created a database with the example of the variables you reported to facilitate.
dados <- data.frame(
inicio = c("2018-06-01 12:00", "2018-06-01 11:00", "2018-06-01 15:20"),
minuto1 = c(105, 90, 80) )
I used the package chron
library(chron)
#criação da variável horas_inicias, extraindo essa informação de inicio
dados$horas_inicio <- as.character(substr(dados$inicio, 12, 16))
#acréscimo de segundos para utilizar a função times
dados$horas_inicio <- paste0(dados$horas_inicio, ":00")
#transformação da variável para tempo
dados$horas_inicio <- times(dados$horas_inicio)
#criação da variável horas, transformando minutos
dados$horas <- times((dados$minuto1%/%60 + dados$minuto1%%60 /60)/24)
#cálculo da diferença de tempo entre as variáveis criadas
dados$diferença <- dados$horas_inicio - dados$horas
@Marcusnunes I understand that now he is wanting the opposite. On this question that you linked, he would like to turn hours into minutes and now he wants to turn minutes into hours and then do some operations.
– Rafael Cunha
Luis I recommend that you, when creating a question here on the site, put your database, or a part of it so that we can help you easier. Search about the command
dput
in theR
– Rafael Cunha
I understand your point, but wouldn’t one question be the other? I imagine that the AP can interpret the code provided in the link I put and perform the reverse operation if tried. Note that the question even has an attempt to solve.
– Marcus Nunes
@Marcusnunes you are covered with reason. It is easier to create a new question than to dwell on attempts
– Rafael Cunha
Good afternoon guys, sorry the delay in responding, What happens I have a column Tempototal = c("15/08/2018 06:00", "16/08/2018 10:35") solo = c("01:00", "02:00") and start.de.use that has to be c("15/08/2018 05:00", "16/08/2018 08:35") So I asked the first question, now I have to convert the minutes into hours, subtract those minutes from the tempototal column, and create a new column with the date field and the time of this subtraction.
– Luis Henrique