Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in cut.default(ts, breaks = breaks) : 'x' must be numeric -- if the first column named differently than HEADER_TIME_STAMP #29

Closed
martakarass opened this issue Apr 13, 2021 · 1 comment
Assignees
Labels

Comments

@martakarass
Copy link

I ran into Error in cut.default(ts, breaks = breaks) : 'x' must be numeric error if using a data frame where the first column -- the time component -- is named differently than "HEADER_TIME_STAMP". Note the documentation does not mention a need to name the first column -- the time component -- in a certain way; it only says df -- dataframe. Input multi-channel accelerometer signal. The first column should be the time component.

Below is an example of generating the error for raw accelerometry data sample included in adeptdata R package. These data were collected continuously for ~20 minutes with ActiGraph Link device at frequency 100 Hz.

Example when it works:

rm(list = ls())

# install.packages("adeptdata")
library(adeptdata)
library(MIMSunit)
library(dplyr)
library(lubridate)

# does work 
df <- adeptdata::acc_running %>% 
  filter(loc_id == "left_hip") %>%
  select(HEADER_TIME_STAMP = date_time, x, y, z) %>%
  mutate(HEADER_TIME_STAMP = lubridate::ymd_hms(HEADER_TIME_STAMP))

mims_out <- MIMSunit::mims_unit(df, epoch = "1 min", dynamic_range = c(-8, 8))
mims_out
     HEADER_TIME_STAMP MIMS_UNIT
1  2018-10-25 17:57:30 -0.010000
2  2018-10-25 17:58:00  2.851872
3  2018-10-25 17:59:00  3.398222
4  2018-10-25 18:00:00  3.546349
5  2018-10-25 18:01:00  3.948084
6  2018-10-25 18:02:00  3.733877
7  2018-10-25 18:03:00  3.495979
8  2018-10-25 18:04:00  0.000000
9  2018-10-25 18:05:00  3.564741
10 2018-10-25 18:06:00  5.340143
11 2018-10-25 18:07:00  3.285434
12 2018-10-25 18:08:00  3.234805
13 2018-10-25 18:09:00  3.635066
14 2018-10-25 18:10:00  2.391141
15 2018-10-25 18:11:00  1.296743
16 2018-10-25 18:12:00  4.239850
17 2018-10-25 18:13:00  2.843946
18 2018-10-25 18:14:00  3.699698
19 2018-10-25 18:15:00  3.670837
20 2018-10-25 18:16:00  3.494550
21 2018-10-25 18:17:00  1.699157
22 2018-10-25 18:18:00  2.959040
23 2018-10-25 18:19:00  4.022677
24 2018-10-25 18:20:00  4.234644
25 2018-10-25 18:21:00  2.658034
26 2018-10-25 18:22:00 -0.010000
  • Example when it does not:
# does not work 
rm(df, mims_out)
df <- adeptdata::acc_running %>% 
  filter(loc_id == "left_hip") %>%
  select(date_time, x, y, z) %>%
  mutate(date_time = lubridate::ymd_hms(date_time))
mims_out <- MIMSunit::mims_unit(df, epoch = "1 min", dynamic_range = c(-8, 8))
===================================================================================Error in cut.default(ts, breaks = breaks) : 'x' must be numeric
In addition: Warning messages:
1: In regularize.values(x, y, ties, missing(ties)) :
  collapsing to unique 'x' values
2: In regularize.values(x, y, ties, missing(ties)) :
  collapsing to unique 'x' values
3: In regularize.values(x, y, ties, missing(ties)) :
  collapsing to unique 'x' values
4: tz(): Don't know how to compute timezone for object of class NULL; returning "UTC". This warning will become an error in the next major version of lubridate. 
Session info
devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.0.3 (2020-10-10)
 os       macOS Catalina 10.15.7      
 system   x86_64, darwin17.0          
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/New_York            
 date     2021-04-12                  

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────
 package     * version  date       lib source        
 adeptdata   * 1.1      2021-03-24 [1] local         
 assertthat    0.2.1    2019-03-21 [1] CRAN (R 4.0.2)
 bitops        1.0-6    2013-08-17 [1] CRAN (R 4.0.2)
 cachem        1.0.4    2021-02-13 [1] CRAN (R 4.0.2)
 callr         3.5.1    2020-10-13 [1] CRAN (R 4.0.2)
 caTools       1.18.1   2021-01-11 [1] CRAN (R 4.0.2)
 cellranger    1.1.0    2016-07-27 [1] CRAN (R 4.0.2)
 cli           2.3.0    2021-01-31 [1] CRAN (R 4.0.3)
 crayon        1.4.1    2021-02-08 [1] CRAN (R 4.0.2)
 DBI           1.1.1    2021-01-15 [1] CRAN (R 4.0.2)
 desc          1.2.0    2018-05-01 [1] CRAN (R 4.0.2)
 devtools      2.3.2    2020-09-18 [1] CRAN (R 4.0.2)
 digest        0.6.27   2020-10-24 [1] CRAN (R 4.0.2)
 dplyr       * 1.0.4    2021-02-02 [1] CRAN (R 4.0.2)
 ellipsis      0.3.1    2020-05-15 [1] CRAN (R 4.0.2)
 fansi         0.4.2    2021-01-15 [1] CRAN (R 4.0.2)
 fastmap       1.1.0    2021-01-25 [1] CRAN (R 4.0.2)
 fs            1.5.0    2020-07-31 [1] CRAN (R 4.0.2)
 generics      0.1.0    2020-10-31 [1] CRAN (R 4.0.2)
 glue          1.4.2    2020-08-27 [1] CRAN (R 4.0.2)
 htmltools     0.5.1.1  2021-01-22 [1] CRAN (R 4.0.2)
 httpuv        1.5.5    2021-01-13 [1] CRAN (R 4.0.2)
 later         1.1.0.1  2020-06-05 [1] CRAN (R 4.0.2)
 lifecycle     1.0.0    2021-02-15 [1] CRAN (R 4.0.2)
 lubridate   * 1.7.9.2  2020-11-13 [1] CRAN (R 4.0.2)
 magrittr      2.0.1    2020-11-17 [1] CRAN (R 4.0.2)
 MASS          7.3-53.1 2021-02-12 [1] CRAN (R 4.0.2)
 memoise       2.0.0    2021-01-26 [1] CRAN (R 4.0.2)
 mime          0.10     2021-02-13 [1] CRAN (R 4.0.2)
 MIMSunit    * 0.9.2    2020-08-01 [1] CRAN (R 4.0.2)
 pillar        1.5.0    2021-02-22 [1] CRAN (R 4.0.3)
 pkgbuild      1.2.0    2020-12-15 [1] CRAN (R 4.0.2)
 pkgconfig     2.0.3    2019-09-22 [1] CRAN (R 4.0.2)
 pkgload       1.1.0    2020-05-29 [1] CRAN (R 4.0.2)
 plyr          1.8.6    2020-03-03 [1] CRAN (R 4.0.2)
 prettyunits   1.1.1    2020-01-24 [1] CRAN (R 4.0.2)
 processx      3.4.5    2020-11-30 [1] CRAN (R 4.0.2)
 promises      1.2.0.1  2021-02-11 [1] CRAN (R 4.0.2)
 ps            1.5.0    2020-12-05 [1] CRAN (R 4.0.2)
 purrr         0.3.4    2020-04-17 [1] CRAN (R 4.0.2)
 R6            2.5.0    2020-10-28 [1] CRAN (R 4.0.2)
 Rcpp          1.0.6    2021-01-15 [1] CRAN (R 4.0.2)
 readxl        1.3.1    2019-03-13 [1] CRAN (R 4.0.2)
 remotes       2.2.0    2020-07-21 [1] CRAN (R 4.0.2)
 rlang         0.4.10   2020-12-30 [1] CRAN (R 4.0.2)
 rprojroot     2.0.2    2020-11-15 [1] CRAN (R 4.0.2)
 sessioninfo   1.1.1    2018-11-05 [1] CRAN (R 4.0.2)
 shiny         1.6.0    2021-01-25 [1] CRAN (R 4.0.2)
 signal        0.7-6    2015-07-30 [1] CRAN (R 4.0.2)
 stringi       1.5.3    2020-09-09 [1] CRAN (R 4.0.2)
 stringr       1.4.0    2019-02-10 [1] CRAN (R 4.0.2)
 testthat      3.0.2    2021-02-14 [1] CRAN (R 4.0.2)
 tibble        3.0.6    2021-01-29 [1] CRAN (R 4.0.2)
 tidyselect    1.1.0    2020-05-11 [1] CRAN (R 4.0.2)
 usethis       2.0.1    2021-02-10 [1] CRAN (R 4.0.2)
 utf8          1.1.4    2018-05-24 [1] CRAN (R 4.0.2)
 vctrs         0.3.6    2020-12-17 [1] CRAN (R 4.0.2)
 withr         2.4.1    2021-01-26 [1] CRAN (R 4.0.2)
 xtable        1.8-4    2019-04-21 [1] CRAN (R 4.0.2)

[1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
@martakarass martakarass changed the title Error in cut.default(ts, breaks = breaks) : 'x' must be numeric -- if the first column named differently than HEADER_TIME_STAMP? Error in cut.default(ts, breaks = breaks) : 'x' must be numeric -- if the first column named differently than HEADER_TIME_STAMP Apr 13, 2021
@qutang
Copy link
Member

qutang commented Apr 13, 2021

Thanks for reporting. I spotted the bug in the code. I'll update the codes to fix it. For now, just make sure you used "HEADER_TIME_STAMP" as the column name.

Thanks.

@qutang qutang self-assigned this Apr 13, 2021
@qutang qutang added the bug label Apr 13, 2021
@qutang qutang closed this as completed in 47e4bf8 Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants