DavisVaughan/ivs

Can't display ivs with View() in RStudio

arohland opened this issue · 3 comments

When I want to look at any dataframe that has an column of type iv I get an error when trying to look at the data using View() in Rstudio.
For example:

> guests <- tibble(
+   arrive = as.POSIXct(
+     c("2008-05-20 19:30:00", "2008-05-20 20:10:00", "2008-05-20 22:15:00"),
+     tz = "UTC"
+   ),
+   depart = as.POSIXct(
+     c("2008-05-20 23:00:00", "2008-05-21 00:00:00", "2008-05-21 00:30:00"),
+     tz = "UTC"
+   ),
+   name = list(
+     c("Mary", "Harry"),
+     c("Diana", "Susan"),
+     "Peter"
+   )
+ )
> 
> guests <- unnest(guests, name) %>%
+   mutate(iv = iv(arrive, depart), .keep = "unused")
> 
> View(guests)
Error in `as.character()`:
! Can't convert `x` <iv<datetime<UTC>>> to <character>.
Run `rlang::last_error()` to see where the error occurred.
Error in `as.character()`:
! Can't convert `x` <iv<datetime<UTC>>> to <character>.
Run `rlang::last_error()` to see where the error occurred.`

Sessioninfo is

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

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

other attached packages:
 [1] ivs_0.1.0         tidyr_1.2.0       tictoc_1.0.1      target.me_0.5.1  
 [5] stringr_1.4.0     readr_2.1.2       purrr_0.3.4       lubridate_1.8.0  
 [9] jsonlite_1.8.0    his.target_0.3.1  glue_1.6.2        furrr_0.3.0      
[13] future_1.26.1     fastDummies_1.6.3 dplyr_1.0.9       crayon_1.5.1     
[17] conflicted_1.1.0  caret_6.0-92      lattice_0.20-45   ggplot2_3.3.6    
[21] bigrquery_1.4.0   big.target_0.10.0 pacman_0.5.1      yaml_2.3.5       
[25] DBI_1.1.3         knitr_1.39.5     

loaded via a namespace (and not attached):
 [1] nlme_3.1-157         fs_1.5.2             bit64_4.0.5         
 [4] progress_1.2.2       httr_1.4.3           rprojroot_2.0.3     
 [7] backports_1.4.1      tools_4.2.1          utf8_1.2.2          
[10] R6_2.5.1             rpart_4.1.16         colorspace_2.0-3    
[13] nnet_7.3-17          withr_2.5.0          prettyunits_1.1.1   
[16] tidyselect_1.1.2     sodium_1.2.1         bit_4.0.4           
[19] curl_4.3.2           compiler_4.2.1       rvest_1.0.2         
[22] cli_3.3.0            xml2_1.3.3           scales_1.2.0        
[25] askpass_1.1          digest_0.6.29        base64enc_0.1-3     
[28] safer_0.2.1          pkgconfig_2.0.3      parallelly_1.32.0   
[31] dbplyr_2.2.1         fastmap_1.1.0        readxl_1.4.0        
[34] rlang_1.0.4          rstudioapi_0.13      generics_0.1.3      
[37] googlesheets4_1.0.0  ModelMetrics_1.2.2.2 magrittr_2.0.3      
[40] Matrix_1.4-1         Rcpp_1.0.9           munsell_0.5.0       
[43] fansi_1.0.3          lifecycle_1.0.1      stringi_1.7.8       
[46] pROC_1.18.0          MASS_7.3-57          plyr_1.8.7          
[49] recipes_1.0.1        grid_4.2.1           parallel_4.2.1      
[52] listenv_0.8.0        forcats_0.5.1        haven_2.5.0         
[55] splines_4.2.1        hms_1.1.1            pillar_1.8.0        
[58] future.apply_1.9.0   reshape2_1.4.4       codetools_0.2-18    
[61] stats4_4.2.1         reprex_2.0.1         modelr_0.1.8        
[64] data.table_1.14.2    remotes_2.4.2        vctrs_0.4.1         
[67] tzdb_0.3.0           foreach_1.5.2        cellranger_1.1.0    
[70] openssl_2.0.2        gtable_0.3.0         assertthat_0.2.1    
[73] cachem_1.0.6         xfun_0.31            gower_1.0.0         
[76] prodlim_2019.11.13   broom_1.0.0          tidyverse_1.3.2     
[79] googledrive_2.0.0    class_7.3-20         survival_3.3-1      
[82] gargle_1.2.0         timeDate_3043.102    tibble_3.1.7        
[85] iterators_1.0.14     memoise_2.0.1        hardhat_1.2.0       
[88] lava_1.6.10          globals_0.15.1       ellipsis_0.3.2      
[91] ipred_0.9-13  

> RStudio.Version()
$citation

To cite RStudio in publications use:

  RStudio Team (2022). RStudio: Integrated Development Environment for R.
  RStudio, PBC, Boston, MA URL http://www.rstudio.com/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{RStudio Team}},
    organization = {RStudio, PBC},
    address = {Boston, MA},
    year = {2022},
    url = {http://www.rstudio.com/},
  }


$mode
[1] "server"

$edition
[1] "Professional"

$version
[1] ‘2022.2.3.492.3’

$long_version
[1] "2022.02.3+492.pro3"

$release_name
[1] "Prairie Trillium"

This was fixed in the latest version of RStudio. It was an RStudio bug, not an ivs one.
rstudio/rstudio#10073

You should be able to get it from here:
https://www.rstudio.com/products/rstudio/download/#download

Screen Shot 2022-07-19 at 9 47 35 AM

That fixed it, thanks a lot for pointing me in the right direction.
I'm a big fan of the package. I've been playing around with IRanges but ivs serves my purpose way better.

Happy to hear it! Let me know if you have any other questions with it