Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [difftime]

A function in R that calculates the difference of two times.

difftime
0 votes
1 answer
37 views

How do I resolve error: objectnotfound, difftime() function in R Language

I have two columns ended_at and started_at. I want to calculate the time difference using this code below all_trips <- Dfftime(all-trips&ended_at, all_trips&started_at) but it keeps ...
gbolahan tanimowo's user avatar
0 votes
0 answers
37 views

R POSIXct date difference produce artificial decimal places

I have a POSIXct date column, and try to baseline it. However, I found the difftime() (or just -) operation produce artificial decimal places that should never exist. >center_coor[,dateTime] [1] &...
Jinjin's user avatar
  • 590
1 vote
3 answers
94 views

Use of "cumsum", "difftime" and "lag"

I have three columns in my dataset that I work on for this question. The first column is called buffer and shows whether a GPS point of an animal is inside the buffer zone (yes/no values). The second ...
Ioannis's user avatar
  • 11
0 votes
0 answers
59 views

Is there an R function to subtract two date time data?

I have two columns of data that are dttm that I'm trying to get the difference from to then get the total average. Essentially I have a start time to a trip, an end time. I'd like to know the ...
Jabe Milam's user avatar
4 votes
4 answers
68 views

How to select for rows in a dataframe that have a time within 30 minutes of another dataframe

I have 2 datasets that looks like the following (with about 600 total entries for both) Dataframe1 name A_time measurement_A A 6/10/22 7:22 3.4 A 6/10/22 16:15 4.4 A 6/11/22 6:15 5.5 A 6/11/22 15:...
ol1975's user avatar
  • 51
0 votes
2 answers
82 views

r Language - Difftime function - Why do I get an error?

I have two different variables (ended_at, started_at) containing times in a chr data type in a dataframe called all_trips. Data from all_trips. started_at ended_at 1 2019-01-01 ...
SnakePlissken's user avatar
2 votes
2 answers
37 views

R difftime output different depending on input formats (as.character() wrapper vs without)

example data: test <- structure(list(date1 = structure(c(1632745800, 1632745800), tzone = "UTC", class = c("POSIXct", "POSIXt")), date2 = structure(c(1641468180, ...
vizidea's user avatar
  • 193
0 votes
0 answers
45 views

The time interval in hours using difftime and if else statements

R script. I want to do the following. The dataset is grouped by pid, med and date1. If pid or med changes then the hours_output == 255, otherwise the hours_output == the time interval in hours. If the ...
db2020's user avatar
  • 135
1 vote
3 answers
48 views

Last value manually inputted in an r script difftime output

R coding in Databricks. I want the time intervals in hours between date1 entries, arranged by pid, med and date1. I want the latest date1 entry in a sequence of events per date to be manually ...
db2020's user avatar
  • 135
1 vote
0 answers
59 views

label is removed from difftime variables after dplyr::filter

When I dplyr::filter a data.frame with labels, the labels remain but not for variables of class difftime: library(tidyverse) library(sjlabelled) df <- data.frame(a = c(1, 2, 3), ...
user63230's user avatar
  • 4,492
-1 votes
1 answer
153 views

Rounding the mean of difftime

In my R data.table mdt below, I have calculated a difference in dates using subtraction (simple mathematical expression) as days_elapsed1 and days_elapsed2. The class of these two objects is "...
sunflower's user avatar
-1 votes
1 answer
97 views

R difftime() producing incorrect intervals

The data was imported from a CSV file, with the dates originally in characters. I have mutated them separately as I want to do some further analysis on them. The only other question on the topic I can ...
Pendragon's user avatar
  • 119
0 votes
1 answer
25 views

How can I add the date of the data that satisfies a condition in ifelse in R?

I need to date and time of the data that satisfies a condition in ifelse. Glucose_4h <- character() for(i in 1:96){ A <- unlist(difftime(Time_Meal[i], Time_Glucose[1:15372], units="mins&...
user21528954's user avatar
1 vote
1 answer
33 views

I have 2 kinds of posts (sponsored and non sponsored) for X users. I want to know for each post of a user when the last sponsored post happened (days)

I have 2 kinds of posts (sponsored and non sponsored) for many users. I know the date when each post happened. Now I need to know for each post of a user when the last sponsored post happened (in ...
Max Di Milian's user avatar
2 votes
4 answers
99 views

To calculate time differences, is there a way to change all : in a data frame?

I was wondering if there is a way to make all colons in a data frame a period? Or delete them from a data set all together? I have asked people what time they went to sleep and they've put 21:00 for ...
Ella's user avatar
  • 23

15 30 50 per page
1
2 3 4 5
13