dplyr::arrange refuse to arrange dataframe by timestamp column?











up vote
1
down vote

favorite












I have the following dataframe (here is the sample):



df <- structure(list(user_id = c(1L, 1L, 1L, 1L, 1L, 1L), obs_id = c(1L, 
2L, 2L, 2L, 2L, 2L), scroll_id = c(3L, 1L, 2L, 3L, 4L, 5L), timestamp = c(-1.74966971796047,
-1.70403832189443, -1.70379906928687, -1.70361867040459, -1.70347088963619,
-1.70319128699835), row_num = 1:6, scroll_length = c(6, 9, 14,
12, 13, 26), x_mean = c(-1.74134749014902, -1.19087086808828,
1.36178725012622, -1.32786301490502, 1.24184201608646, -1.31953110973881
), y_mean = c(-4.93507461932646, 0.0304680987883223, 0.140001980341645,
0.61911843405746, 0.434230282460559, 0.438563278736709), dx_mean = c(-0.514034686928457,
-0.709482080612108, 0.924636289935977, -0.702980646737082, 0.515080876392673,
-0.359676884238743), dy_mean = c(0.972265996197407, -0.692113718739584,
-0.162463490249733, -0.373682612876388, -0.0663766957581004,
0.293619375985922)), .Names = c("user_id", "obs_id", "scroll_id",
"timestamp", "row_num", "scroll_length", "x_mean", "y_mean",
"dx_mean", "dy_mean"), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))


I want to arrange by timestamp column but I get the following error:



data %>% arrange(timestamp)
data %>% arrange("timestamp")



Error in arrange_impl(.data, dots) : Argument 1 is of unsupported type
matrix




Please advise how to make it work. I know that timestamp is a function and matrix but here it's a column and I "want" dplyr to "understand" that it's a column.



As @sotos asked:



sessionInfo():

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_IL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_IL.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_IL.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] bindrcpp_0.2.2 rebus_0.1-3 philentropy_0.2.0 reshape2_1.4.3 broom_0.5.0 dummies_1.5.6 hms_0.4.2
[8] anytime_0.3.1 data.table_1.11.8 bit64_0.9-7 bit_1.1-14 car_3.0-2 carData_3.0-2 caret_6.0-80
[15] lattice_0.20-35 xgboost_0.71.2 doSNOW_1.0.16 snow_0.4-3 doMC_1.3.5 iterators_1.0.10 foreach_1.4.4
[22] randomForest_4.6-14 htmlwidgets_1.3 plotly_4.8.0 jsonlite_1.5 pROC_1.13.0 knitr_1.20 lubridate_1.7.4
[29] MASS_7.3-49 chron_2.3-53 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.7 purrr_0.2.5 readr_1.1.1
[36] tidyr_0.8.2 tibble_1.4.2 ggplot2_3.1.0 tidyverse_1.2.1

loaded via a namespace (and not attached):
[1] nlme_3.1-137 dimRed_0.1.0 httr_1.3.1 tools_3.4.4 backports_1.1.2 R6_2.3.0
[7] rpart_4.1-13 rebus.base_0.0-3 lazyeval_0.2.1 colorspace_1.3-2 nnet_7.3-12 withr_2.1.2
[13] tidyselect_0.2.5 curl_3.1 compiler_3.4.4 cli_1.0.1 rvest_0.3.2 xml2_1.2.0
[19] scales_1.0.0 sfsmisc_1.1-2 DEoptimR_1.0-8 robustbase_0.93-3 RApiDatetime_0.0.4 digest_0.6.18
[25] rebus.unicode_0.0-2 foreign_0.8-70 rio_0.5.10 pkgconfig_2.0.2 htmltools_0.3.6 rlang_0.3.0.1
[31] readxl_1.1.0 ddalpha_1.3.4 rstudioapi_0.8 bindr_0.1.1 zip_1.0.0 ModelMetrics_1.2.0
[37] magrittr_1.5 Matrix_1.2-14 Rcpp_0.12.19 munsell_0.5.0 abind_1.4-5 stringi_1.2.4
[43] yaml_2.2.0 plyr_1.8.4 recipes_0.1.3 grid_3.4.4 pls_2.7-0 crayon_1.3.4
[49] rebus.datetimes_0.0-1 haven_1.1.2 splines_3.4.4 pillar_1.3.0 rebus.numbers_0.0-1 codetools_0.2-15
[55] stats4_3.4.4 CVST_0.2-2 magic_1.5-9 glue_1.3.0 modelr_0.1.2 cellranger_1.1.0
[61] gtable_0.2.0 kernlab_0.9-27 assertthat_0.2.0 DRR_0.0.3 openxlsx_4.1.0 gower_0.1.2
[67] prodlim_2018.04.18 class_7.3-14 survival_2.42-3 viridisLite_0.3.0 geometry_0.3-6 timeDate_3043.102
[73] RcppRoll_0.3.0 lava_1.6.3 ipred_0.9-7









share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 8 at 11:21















up vote
1
down vote

favorite












I have the following dataframe (here is the sample):



df <- structure(list(user_id = c(1L, 1L, 1L, 1L, 1L, 1L), obs_id = c(1L, 
2L, 2L, 2L, 2L, 2L), scroll_id = c(3L, 1L, 2L, 3L, 4L, 5L), timestamp = c(-1.74966971796047,
-1.70403832189443, -1.70379906928687, -1.70361867040459, -1.70347088963619,
-1.70319128699835), row_num = 1:6, scroll_length = c(6, 9, 14,
12, 13, 26), x_mean = c(-1.74134749014902, -1.19087086808828,
1.36178725012622, -1.32786301490502, 1.24184201608646, -1.31953110973881
), y_mean = c(-4.93507461932646, 0.0304680987883223, 0.140001980341645,
0.61911843405746, 0.434230282460559, 0.438563278736709), dx_mean = c(-0.514034686928457,
-0.709482080612108, 0.924636289935977, -0.702980646737082, 0.515080876392673,
-0.359676884238743), dy_mean = c(0.972265996197407, -0.692113718739584,
-0.162463490249733, -0.373682612876388, -0.0663766957581004,
0.293619375985922)), .Names = c("user_id", "obs_id", "scroll_id",
"timestamp", "row_num", "scroll_length", "x_mean", "y_mean",
"dx_mean", "dy_mean"), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))


I want to arrange by timestamp column but I get the following error:



data %>% arrange(timestamp)
data %>% arrange("timestamp")



Error in arrange_impl(.data, dots) : Argument 1 is of unsupported type
matrix




Please advise how to make it work. I know that timestamp is a function and matrix but here it's a column and I "want" dplyr to "understand" that it's a column.



As @sotos asked:



sessionInfo():

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_IL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_IL.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_IL.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] bindrcpp_0.2.2 rebus_0.1-3 philentropy_0.2.0 reshape2_1.4.3 broom_0.5.0 dummies_1.5.6 hms_0.4.2
[8] anytime_0.3.1 data.table_1.11.8 bit64_0.9-7 bit_1.1-14 car_3.0-2 carData_3.0-2 caret_6.0-80
[15] lattice_0.20-35 xgboost_0.71.2 doSNOW_1.0.16 snow_0.4-3 doMC_1.3.5 iterators_1.0.10 foreach_1.4.4
[22] randomForest_4.6-14 htmlwidgets_1.3 plotly_4.8.0 jsonlite_1.5 pROC_1.13.0 knitr_1.20 lubridate_1.7.4
[29] MASS_7.3-49 chron_2.3-53 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.7 purrr_0.2.5 readr_1.1.1
[36] tidyr_0.8.2 tibble_1.4.2 ggplot2_3.1.0 tidyverse_1.2.1

loaded via a namespace (and not attached):
[1] nlme_3.1-137 dimRed_0.1.0 httr_1.3.1 tools_3.4.4 backports_1.1.2 R6_2.3.0
[7] rpart_4.1-13 rebus.base_0.0-3 lazyeval_0.2.1 colorspace_1.3-2 nnet_7.3-12 withr_2.1.2
[13] tidyselect_0.2.5 curl_3.1 compiler_3.4.4 cli_1.0.1 rvest_0.3.2 xml2_1.2.0
[19] scales_1.0.0 sfsmisc_1.1-2 DEoptimR_1.0-8 robustbase_0.93-3 RApiDatetime_0.0.4 digest_0.6.18
[25] rebus.unicode_0.0-2 foreign_0.8-70 rio_0.5.10 pkgconfig_2.0.2 htmltools_0.3.6 rlang_0.3.0.1
[31] readxl_1.1.0 ddalpha_1.3.4 rstudioapi_0.8 bindr_0.1.1 zip_1.0.0 ModelMetrics_1.2.0
[37] magrittr_1.5 Matrix_1.2-14 Rcpp_0.12.19 munsell_0.5.0 abind_1.4-5 stringi_1.2.4
[43] yaml_2.2.0 plyr_1.8.4 recipes_0.1.3 grid_3.4.4 pls_2.7-0 crayon_1.3.4
[49] rebus.datetimes_0.0-1 haven_1.1.2 splines_3.4.4 pillar_1.3.0 rebus.numbers_0.0-1 codetools_0.2-15
[55] stats4_3.4.4 CVST_0.2-2 magic_1.5-9 glue_1.3.0 modelr_0.1.2 cellranger_1.1.0
[61] gtable_0.2.0 kernlab_0.9-27 assertthat_0.2.0 DRR_0.0.3 openxlsx_4.1.0 gower_0.1.2
[67] prodlim_2018.04.18 class_7.3-14 survival_2.42-3 viridisLite_0.3.0 geometry_0.3-6 timeDate_3043.102
[73] RcppRoll_0.3.0 lava_1.6.3 ipred_0.9-7









share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 8 at 11:21













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have the following dataframe (here is the sample):



df <- structure(list(user_id = c(1L, 1L, 1L, 1L, 1L, 1L), obs_id = c(1L, 
2L, 2L, 2L, 2L, 2L), scroll_id = c(3L, 1L, 2L, 3L, 4L, 5L), timestamp = c(-1.74966971796047,
-1.70403832189443, -1.70379906928687, -1.70361867040459, -1.70347088963619,
-1.70319128699835), row_num = 1:6, scroll_length = c(6, 9, 14,
12, 13, 26), x_mean = c(-1.74134749014902, -1.19087086808828,
1.36178725012622, -1.32786301490502, 1.24184201608646, -1.31953110973881
), y_mean = c(-4.93507461932646, 0.0304680987883223, 0.140001980341645,
0.61911843405746, 0.434230282460559, 0.438563278736709), dx_mean = c(-0.514034686928457,
-0.709482080612108, 0.924636289935977, -0.702980646737082, 0.515080876392673,
-0.359676884238743), dy_mean = c(0.972265996197407, -0.692113718739584,
-0.162463490249733, -0.373682612876388, -0.0663766957581004,
0.293619375985922)), .Names = c("user_id", "obs_id", "scroll_id",
"timestamp", "row_num", "scroll_length", "x_mean", "y_mean",
"dx_mean", "dy_mean"), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))


I want to arrange by timestamp column but I get the following error:



data %>% arrange(timestamp)
data %>% arrange("timestamp")



Error in arrange_impl(.data, dots) : Argument 1 is of unsupported type
matrix




Please advise how to make it work. I know that timestamp is a function and matrix but here it's a column and I "want" dplyr to "understand" that it's a column.



As @sotos asked:



sessionInfo():

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_IL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_IL.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_IL.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] bindrcpp_0.2.2 rebus_0.1-3 philentropy_0.2.0 reshape2_1.4.3 broom_0.5.0 dummies_1.5.6 hms_0.4.2
[8] anytime_0.3.1 data.table_1.11.8 bit64_0.9-7 bit_1.1-14 car_3.0-2 carData_3.0-2 caret_6.0-80
[15] lattice_0.20-35 xgboost_0.71.2 doSNOW_1.0.16 snow_0.4-3 doMC_1.3.5 iterators_1.0.10 foreach_1.4.4
[22] randomForest_4.6-14 htmlwidgets_1.3 plotly_4.8.0 jsonlite_1.5 pROC_1.13.0 knitr_1.20 lubridate_1.7.4
[29] MASS_7.3-49 chron_2.3-53 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.7 purrr_0.2.5 readr_1.1.1
[36] tidyr_0.8.2 tibble_1.4.2 ggplot2_3.1.0 tidyverse_1.2.1

loaded via a namespace (and not attached):
[1] nlme_3.1-137 dimRed_0.1.0 httr_1.3.1 tools_3.4.4 backports_1.1.2 R6_2.3.0
[7] rpart_4.1-13 rebus.base_0.0-3 lazyeval_0.2.1 colorspace_1.3-2 nnet_7.3-12 withr_2.1.2
[13] tidyselect_0.2.5 curl_3.1 compiler_3.4.4 cli_1.0.1 rvest_0.3.2 xml2_1.2.0
[19] scales_1.0.0 sfsmisc_1.1-2 DEoptimR_1.0-8 robustbase_0.93-3 RApiDatetime_0.0.4 digest_0.6.18
[25] rebus.unicode_0.0-2 foreign_0.8-70 rio_0.5.10 pkgconfig_2.0.2 htmltools_0.3.6 rlang_0.3.0.1
[31] readxl_1.1.0 ddalpha_1.3.4 rstudioapi_0.8 bindr_0.1.1 zip_1.0.0 ModelMetrics_1.2.0
[37] magrittr_1.5 Matrix_1.2-14 Rcpp_0.12.19 munsell_0.5.0 abind_1.4-5 stringi_1.2.4
[43] yaml_2.2.0 plyr_1.8.4 recipes_0.1.3 grid_3.4.4 pls_2.7-0 crayon_1.3.4
[49] rebus.datetimes_0.0-1 haven_1.1.2 splines_3.4.4 pillar_1.3.0 rebus.numbers_0.0-1 codetools_0.2-15
[55] stats4_3.4.4 CVST_0.2-2 magic_1.5-9 glue_1.3.0 modelr_0.1.2 cellranger_1.1.0
[61] gtable_0.2.0 kernlab_0.9-27 assertthat_0.2.0 DRR_0.0.3 openxlsx_4.1.0 gower_0.1.2
[67] prodlim_2018.04.18 class_7.3-14 survival_2.42-3 viridisLite_0.3.0 geometry_0.3-6 timeDate_3043.102
[73] RcppRoll_0.3.0 lava_1.6.3 ipred_0.9-7









share|improve this question















I have the following dataframe (here is the sample):



df <- structure(list(user_id = c(1L, 1L, 1L, 1L, 1L, 1L), obs_id = c(1L, 
2L, 2L, 2L, 2L, 2L), scroll_id = c(3L, 1L, 2L, 3L, 4L, 5L), timestamp = c(-1.74966971796047,
-1.70403832189443, -1.70379906928687, -1.70361867040459, -1.70347088963619,
-1.70319128699835), row_num = 1:6, scroll_length = c(6, 9, 14,
12, 13, 26), x_mean = c(-1.74134749014902, -1.19087086808828,
1.36178725012622, -1.32786301490502, 1.24184201608646, -1.31953110973881
), y_mean = c(-4.93507461932646, 0.0304680987883223, 0.140001980341645,
0.61911843405746, 0.434230282460559, 0.438563278736709), dx_mean = c(-0.514034686928457,
-0.709482080612108, 0.924636289935977, -0.702980646737082, 0.515080876392673,
-0.359676884238743), dy_mean = c(0.972265996197407, -0.692113718739584,
-0.162463490249733, -0.373682612876388, -0.0663766957581004,
0.293619375985922)), .Names = c("user_id", "obs_id", "scroll_id",
"timestamp", "row_num", "scroll_length", "x_mean", "y_mean",
"dx_mean", "dy_mean"), row.names = c(NA, -6L), class = c("tbl_df",
"tbl", "data.frame"))


I want to arrange by timestamp column but I get the following error:



data %>% arrange(timestamp)
data %>% arrange("timestamp")



Error in arrange_impl(.data, dots) : Argument 1 is of unsupported type
matrix




Please advise how to make it work. I know that timestamp is a function and matrix but here it's a column and I "want" dplyr to "understand" that it's a column.



As @sotos asked:



sessionInfo():

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_IL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_IL.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_IL.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] bindrcpp_0.2.2 rebus_0.1-3 philentropy_0.2.0 reshape2_1.4.3 broom_0.5.0 dummies_1.5.6 hms_0.4.2
[8] anytime_0.3.1 data.table_1.11.8 bit64_0.9-7 bit_1.1-14 car_3.0-2 carData_3.0-2 caret_6.0-80
[15] lattice_0.20-35 xgboost_0.71.2 doSNOW_1.0.16 snow_0.4-3 doMC_1.3.5 iterators_1.0.10 foreach_1.4.4
[22] randomForest_4.6-14 htmlwidgets_1.3 plotly_4.8.0 jsonlite_1.5 pROC_1.13.0 knitr_1.20 lubridate_1.7.4
[29] MASS_7.3-49 chron_2.3-53 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.7 purrr_0.2.5 readr_1.1.1
[36] tidyr_0.8.2 tibble_1.4.2 ggplot2_3.1.0 tidyverse_1.2.1

loaded via a namespace (and not attached):
[1] nlme_3.1-137 dimRed_0.1.0 httr_1.3.1 tools_3.4.4 backports_1.1.2 R6_2.3.0
[7] rpart_4.1-13 rebus.base_0.0-3 lazyeval_0.2.1 colorspace_1.3-2 nnet_7.3-12 withr_2.1.2
[13] tidyselect_0.2.5 curl_3.1 compiler_3.4.4 cli_1.0.1 rvest_0.3.2 xml2_1.2.0
[19] scales_1.0.0 sfsmisc_1.1-2 DEoptimR_1.0-8 robustbase_0.93-3 RApiDatetime_0.0.4 digest_0.6.18
[25] rebus.unicode_0.0-2 foreign_0.8-70 rio_0.5.10 pkgconfig_2.0.2 htmltools_0.3.6 rlang_0.3.0.1
[31] readxl_1.1.0 ddalpha_1.3.4 rstudioapi_0.8 bindr_0.1.1 zip_1.0.0 ModelMetrics_1.2.0
[37] magrittr_1.5 Matrix_1.2-14 Rcpp_0.12.19 munsell_0.5.0 abind_1.4-5 stringi_1.2.4
[43] yaml_2.2.0 plyr_1.8.4 recipes_0.1.3 grid_3.4.4 pls_2.7-0 crayon_1.3.4
[49] rebus.datetimes_0.0-1 haven_1.1.2 splines_3.4.4 pillar_1.3.0 rebus.numbers_0.0-1 codetools_0.2-15
[55] stats4_3.4.4 CVST_0.2-2 magic_1.5-9 glue_1.3.0 modelr_0.1.2 cellranger_1.1.0
[61] gtable_0.2.0 kernlab_0.9-27 assertthat_0.2.0 DRR_0.0.3 openxlsx_4.1.0 gower_0.1.2
[67] prodlim_2018.04.18 class_7.3-14 survival_2.42-3 viridisLite_0.3.0 geometry_0.3-6 timeDate_3043.102
[73] RcppRoll_0.3.0 lava_1.6.3 ipred_0.9-7






r dataframe dplyr tidyverse






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 9:19

























asked Nov 8 at 9:09









steves

477211




477211












  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 8 at 11:21


















  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 8 at 11:21
















Comments are not for extended discussion; this conversation has been moved to chat.
– Samuel Liew
Nov 8 at 11:21




Comments are not for extended discussion; this conversation has been moved to chat.
– Samuel Liew
Nov 8 at 11:21












2 Answers
2






active

oldest

votes

















up vote
2
down vote













df %>% arrange(timestamp)

arrange() from dplyr arranges as below in ascending order
# A tibble: 6 x 10
user_id obs_id scroll_id timestamp row_num scroll_length x_mean y_mean dx_mean dy_mean
<int> <int> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 1 3 -1.75 1 6 -1.74 -4.94 -0.514 0.972
2 1 2 1 -1.70 2 9 -1.19 0.0305 -0.709 -0.692
3 1 2 2 -1.70 3 14 1.36 0.140 0.925 -0.162
4 1 2 3 -1.70 4 12 -1.33 0.619 -0.703 -0.374
5 1 2 4 -1.70 5 13 1.24 0.434 0.515 -0.0664
6 1 2 5 -1.70 6 26 -1.32 0.439 -0.360 0.294





share|improve this answer






























    up vote
    1
    down vote













    Thanks for all comments, I have found out a solution:



    My df dataframe is scaled and centered - the function that produces df returns:



    scale(df)


    When I have printed str(df) I have seen attributes saying that it's centered and scaled.



    When converting to data.table it solved the issue:



    df %>% as.data.table() %>% dplyr::arrange(obs_id, user_id, scroll_id, timestamp)


    Please correct me if I am wrong.






    share|improve this answer





















    • Nice to see the solution.. also observed uneven number of data points in each variable like dx_mean, dy_mean have only 212 points vs obs_id which is 356 rows?
      – Sai Prabhanjan Reddy
      Nov 8 at 11:16











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204532%2fdplyrarrange-refuse-to-arrange-dataframe-by-timestamp-column%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    df %>% arrange(timestamp)

    arrange() from dplyr arranges as below in ascending order
    # A tibble: 6 x 10
    user_id obs_id scroll_id timestamp row_num scroll_length x_mean y_mean dx_mean dy_mean
    <int> <int> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
    1 1 1 3 -1.75 1 6 -1.74 -4.94 -0.514 0.972
    2 1 2 1 -1.70 2 9 -1.19 0.0305 -0.709 -0.692
    3 1 2 2 -1.70 3 14 1.36 0.140 0.925 -0.162
    4 1 2 3 -1.70 4 12 -1.33 0.619 -0.703 -0.374
    5 1 2 4 -1.70 5 13 1.24 0.434 0.515 -0.0664
    6 1 2 5 -1.70 6 26 -1.32 0.439 -0.360 0.294





    share|improve this answer



























      up vote
      2
      down vote













      df %>% arrange(timestamp)

      arrange() from dplyr arranges as below in ascending order
      # A tibble: 6 x 10
      user_id obs_id scroll_id timestamp row_num scroll_length x_mean y_mean dx_mean dy_mean
      <int> <int> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
      1 1 1 3 -1.75 1 6 -1.74 -4.94 -0.514 0.972
      2 1 2 1 -1.70 2 9 -1.19 0.0305 -0.709 -0.692
      3 1 2 2 -1.70 3 14 1.36 0.140 0.925 -0.162
      4 1 2 3 -1.70 4 12 -1.33 0.619 -0.703 -0.374
      5 1 2 4 -1.70 5 13 1.24 0.434 0.515 -0.0664
      6 1 2 5 -1.70 6 26 -1.32 0.439 -0.360 0.294





      share|improve this answer

























        up vote
        2
        down vote










        up vote
        2
        down vote









        df %>% arrange(timestamp)

        arrange() from dplyr arranges as below in ascending order
        # A tibble: 6 x 10
        user_id obs_id scroll_id timestamp row_num scroll_length x_mean y_mean dx_mean dy_mean
        <int> <int> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
        1 1 1 3 -1.75 1 6 -1.74 -4.94 -0.514 0.972
        2 1 2 1 -1.70 2 9 -1.19 0.0305 -0.709 -0.692
        3 1 2 2 -1.70 3 14 1.36 0.140 0.925 -0.162
        4 1 2 3 -1.70 4 12 -1.33 0.619 -0.703 -0.374
        5 1 2 4 -1.70 5 13 1.24 0.434 0.515 -0.0664
        6 1 2 5 -1.70 6 26 -1.32 0.439 -0.360 0.294





        share|improve this answer














        df %>% arrange(timestamp)

        arrange() from dplyr arranges as below in ascending order
        # A tibble: 6 x 10
        user_id obs_id scroll_id timestamp row_num scroll_length x_mean y_mean dx_mean dy_mean
        <int> <int> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
        1 1 1 3 -1.75 1 6 -1.74 -4.94 -0.514 0.972
        2 1 2 1 -1.70 2 9 -1.19 0.0305 -0.709 -0.692
        3 1 2 2 -1.70 3 14 1.36 0.140 0.925 -0.162
        4 1 2 3 -1.70 4 12 -1.33 0.619 -0.703 -0.374
        5 1 2 4 -1.70 5 13 1.24 0.434 0.515 -0.0664
        6 1 2 5 -1.70 6 26 -1.32 0.439 -0.360 0.294






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 8 at 9:27









        DJV

        1,2231216




        1,2231216










        answered Nov 8 at 9:24









        Sai Prabhanjan Reddy

        1829




        1829
























            up vote
            1
            down vote













            Thanks for all comments, I have found out a solution:



            My df dataframe is scaled and centered - the function that produces df returns:



            scale(df)


            When I have printed str(df) I have seen attributes saying that it's centered and scaled.



            When converting to data.table it solved the issue:



            df %>% as.data.table() %>% dplyr::arrange(obs_id, user_id, scroll_id, timestamp)


            Please correct me if I am wrong.






            share|improve this answer





















            • Nice to see the solution.. also observed uneven number of data points in each variable like dx_mean, dy_mean have only 212 points vs obs_id which is 356 rows?
              – Sai Prabhanjan Reddy
              Nov 8 at 11:16















            up vote
            1
            down vote













            Thanks for all comments, I have found out a solution:



            My df dataframe is scaled and centered - the function that produces df returns:



            scale(df)


            When I have printed str(df) I have seen attributes saying that it's centered and scaled.



            When converting to data.table it solved the issue:



            df %>% as.data.table() %>% dplyr::arrange(obs_id, user_id, scroll_id, timestamp)


            Please correct me if I am wrong.






            share|improve this answer





















            • Nice to see the solution.. also observed uneven number of data points in each variable like dx_mean, dy_mean have only 212 points vs obs_id which is 356 rows?
              – Sai Prabhanjan Reddy
              Nov 8 at 11:16













            up vote
            1
            down vote










            up vote
            1
            down vote









            Thanks for all comments, I have found out a solution:



            My df dataframe is scaled and centered - the function that produces df returns:



            scale(df)


            When I have printed str(df) I have seen attributes saying that it's centered and scaled.



            When converting to data.table it solved the issue:



            df %>% as.data.table() %>% dplyr::arrange(obs_id, user_id, scroll_id, timestamp)


            Please correct me if I am wrong.






            share|improve this answer












            Thanks for all comments, I have found out a solution:



            My df dataframe is scaled and centered - the function that produces df returns:



            scale(df)


            When I have printed str(df) I have seen attributes saying that it's centered and scaled.



            When converting to data.table it solved the issue:



            df %>% as.data.table() %>% dplyr::arrange(obs_id, user_id, scroll_id, timestamp)


            Please correct me if I am wrong.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 8 at 10:50









            steves

            477211




            477211












            • Nice to see the solution.. also observed uneven number of data points in each variable like dx_mean, dy_mean have only 212 points vs obs_id which is 356 rows?
              – Sai Prabhanjan Reddy
              Nov 8 at 11:16


















            • Nice to see the solution.. also observed uneven number of data points in each variable like dx_mean, dy_mean have only 212 points vs obs_id which is 356 rows?
              – Sai Prabhanjan Reddy
              Nov 8 at 11:16
















            Nice to see the solution.. also observed uneven number of data points in each variable like dx_mean, dy_mean have only 212 points vs obs_id which is 356 rows?
            – Sai Prabhanjan Reddy
            Nov 8 at 11:16




            Nice to see the solution.. also observed uneven number of data points in each variable like dx_mean, dy_mean have only 212 points vs obs_id which is 356 rows?
            – Sai Prabhanjan Reddy
            Nov 8 at 11:16


















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204532%2fdplyrarrange-refuse-to-arrange-dataframe-by-timestamp-column%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)