1 year ago

#77341

test-img

ClaireR

Using naive time in clock package and having error with rbind. Error: `levels.clock_naive_time()` not supported

I'm using the clock package to deal with potential problems with time savings. But I'm having a simple problem which is that when I split the dataset and try to recombine it, it won't let me recombine using rbind.

Here is an example of the data:

structure(list(Plant = c("Rose", "Rose", "Rose", "Rose", "Rose"
), Location = c("North", "North", "North", "North", "North"), 
    Count = c(189L, 719L, 189L, 0L, 1523L), BeginDateTime = structure(list(
        ticks = c(18629L, 18629L, 18629L, 18629L, 18629L), ticks_of_day = c(1820L, 
        18620L, 20419L, 22223L, 74418L)), class = c("clock_naive_time", 
    "clock_time_point", "clock_rcrd", "vctrs_rcrd", "vctrs_vctr"
    ), clock = 1L, precision = 7L), EndDateTime = structure(list(
        ticks = c(18629L, 18629L, 18629L, 18629L, 18629L), ticks_of_day = c(18620L, 
        20419L, 22223L, 22223L, 76219L)), class = c("clock_naive_time", 
    "clock_time_point", "clock_rcrd", "vctrs_rcrd", "vctrs_vctr"
    ), clock = 1L, precision = 7L)), row.names = c(NA, -5L), class = c("tbl_df", 
"tbl", "data.frame"))

Here's what I did:

test2<-test[1:3,]
test3<-test[c(4,5),]
test4<-rbind(test2,test3)

And then I got:

Error: `levels.clock_naive_time()` not supported.
Run `rlang::last_error()` to see where the error occurred.
<error/vctrs_error_unsupported>
`levels.clock_naive_time()` not supported.
Backtrace:
 1. base::rbind(test2, test3)
 2. base::rbind(deparse.level, ...)
 4. vctrs:::levels.vctrs_vctr(xj)
 5. vctrs:::stop_unsupported(x, "levels")
 6. vctrs:::stop_vctrs(...)
Run `rlang::last_trace()` to see the full context.

When I ran last_trace() I got

<error/vctrs_error_unsupported>
`levels.clock_naive_time()` not supported.
Backtrace:
    x
 1. \-base::rbind(test2, test3)
 2.   \-base::rbind(deparse.level, ...)
 3.     +-base::levels(xj)
 4.     \-vctrs:::levels.vctrs_vctr(xj)
 5.       \-vctrs:::stop_unsupported(x, "levels")
 6.         \-vctrs:::stop_vctrs(...)

Is this a bug with naive time or am I missing something?

r

time

clock

0 Answers

Your Answer

Accepted video resources