I'm pretty new to r, and so was wondering if someone might be able to help with the error message I've been receiving.
I have a data.frame AUC_sheet
which contains the column AUC_sheet$sys_time
which is in POSIXct and represents the times that blood pressure readings were taken during an operation.
I would like to convert AUC_sheet
out of POSIXct, so that I can get an accurate result during subsequent area under the curve calculations. I've used the following for loop to perform the conversion:
for(i in 1:length(AUC_sheet$sys_time)){
AUC_sheet$sys_time[i] <- as.numeric(difftime(time1 = AUC_sheet$sys_time[1],
time2 = AUC_sheet$sys_time[i], units = "hours"))
}
But I keep getting an error message as follows
Error in as.POSIXct.numeric(value) : 'origin' must be supplied
I've tried using origin = "1970-01-01"
but it tells me this is an unused argument.
Is there something glaringly obvious that I'm doing wrong?
Thanks in advance, and sorry if I've not provided enough data, I can post more as an edit if needed
EDIT AUC_sheet$sys_time looks like this
sys_value sys_time
<dbl> <time>
1 85 2013-08-28 12:48:24
2 NA 2013-08-28 12:48:39
3 NA 2013-08-28 12:48:54
4 NA 2013-08-28 12:49:08
5 NA 2013-08-28 12:49:24
6 170 2013-08-28 12:49:38
7 150 2013-08-28 12:49:54
8 167 2013-08-28 12:50:09
9 175 2013-08-28 12:50:24
10 167 2013-08-28 12:50:39
# ... with 549 more rows