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

dcast doesn't work with complex numbers in value.var. #4855

Closed
eliocamp opened this issue Dec 18, 2020 · 3 comments · Fixed by #4863
Closed

dcast doesn't work with complex numbers in value.var. #4855

eliocamp opened this issue Dec 18, 2020 · 3 comments · Fixed by #4863
Labels
reshape dcast melt
Milestone

Comments

@eliocamp
Copy link
Contributor

I might be wrong, but I think that some versions ago data.table was able to handle complex numbers (#3690). In the CRAN version, I see that I can't dcast when value.var points to a complex vector.

library(data.table)

dt <- CJ(x = 1:10, y = letters[1:3])
dt[, z := complex(real = rnorm(.N), imaginary = rnorm(.N))]

dcast(dt, x ~ y, value.var  = "z")
#> Error in dcast.data.table(dt, x ~ y, value.var = "z"): Unsupported column type in fcast val: 'complex'

Expected output:

reshape2::dcast(dt, x ~ y, value.var  = "z")
#>     x                     a                     b                     c
#> 1   1 -1.3488967+1.1481185i -0.5222023-0.3259327i -0.5009616-0.7509642i
#> 2   2 -1.9949708+0.2536504i -1.3369498-0.4085785i  0.2366162+1.8662590i
#> 3   3  0.6624376+0.1975880i  0.5939629+1.0406464i -0.3498065+0.4978450i
#> 4   4 -0.0458679-1.3673610i  0.9238121-1.2469855i -0.4311840-2.3883511i
#> 5   5 -0.2211641+0.7137510i -1.4004275-0.8080942i  1.2348086-0.2340012i
#> 6   6  0.0606991-1.8565303i -0.8888768+0.9388083i  0.3308363+0.1521898i
#> 7   7 -0.6501890-0.6649984i -1.0598468-0.2198247i  1.4283844-0.9732736i
#> 8   8 -0.1287399-0.4475324i -0.3761322-0.0362629i -1.7031317-0.3632172i
#> 9   9  0.0497523+2.0927461i -0.9403378-1.7611338i  1.1598990-0.3927210i
#> 10 10 -1.5632296-1.5896036i -0.5649199+0.0777556i  0.0734752-1.4180248i

Created on 2020-12-18 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                         
#>  version  R version 4.0.3 (2020-10-10)  
#>  os       elementary OS 5.1.7 Hera      
#>  system   x86_64, linux-gnu             
#>  ui       X11                           
#>  language en_GB:en                      
#>  collate  en_GB.UTF-8                   
#>  ctype    en_GB.UTF-8                   
#>  tz       America/Argentina/Buenos_Aires
#>  date     2020-12-18                    
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                            
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.3)                    
#>  callr         3.5.1      2020-10-13 [1] CRAN (R 4.0.3)                    
#>  cli           2.2.0      2020-11-20 [1] CRAN (R 4.0.3)                    
#>  crayon        1.3.4.9000 2020-11-11 [1] Github (r-lib/crayon@4bceba8)     
#>  data.table  * 1.13.4     2020-12-08 [1] CRAN (R 4.0.3)                    
#>  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.3)                    
#>  ellipsis      0.3.1      2020-05-15 [1] RSPM (R 4.0.2)                    
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.2)                    
#>  fansi         0.4.1      2020-01-08 [1] CRAN (R 4.0.2)                    
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.0.2)                    
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.0.2)                    
#>  highr         0.8        2019-03-20 [1] CRAN (R 4.0.2)                    
#>  htmltools     0.5.0.9003 2020-11-25 [1] Github (rstudio/htmltools@636b95e)
#>  knitr         1.30.2     2020-11-25 [1] Github (yihui/knitr@a00710b)      
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.0.3)                    
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 4.0.2)                    
#>  pkgbuild      1.1.0      2020-07-13 [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] RSPM (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.3)                    
#>  ps            1.5.0      2020-12-05 [1] CRAN (R 4.0.3)                    
#>  R6            2.5.0      2020-10-28 [1] CRAN (R 4.0.3)                    
#>  Rcpp          1.0.5      2020-07-06 [1] CRAN (R 4.0.2)                    
#>  remotes       2.2.0      2020-07-21 [1] CRAN (R 4.0.2)                    
#>  reshape2      1.4.4      2020-04-09 [1] RSPM (R 4.0.2)                    
#>  rlang         0.4.8.9002 2020-11-25 [1] Github (r-lib/rlang@b4e28cb)      
#>  rmarkdown     2.5        2020-10-21 [1] CRAN (R 4.0.3)                    
#>  rprojroot     2.0.2      2020-11-15 [1] CRAN (R 4.0.3)                    
#>  sessioninfo   1.1.1      2018-11-05 [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.0.9000 2020-11-23 [1] Github (r-lib/testthat@45a9c70)   
#>  usethis       1.6.3      2020-09-17 [1] CRAN (R 4.0.2)                    
#>  withr         2.3.0      2020-09-22 [1] CRAN (R 4.0.3)                    
#>  xfun          0.19       2020-10-30 [1] CRAN (R 4.0.3)                    
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.2)                    
#> 
#> [1] /home/elio/R/x86_64-pc-linux-gnu-library/4.0
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library
@eliocamp eliocamp changed the title Possible regresion: dcast doesn't work with complex numbers. Possible regression: dcast doesn't work with complex numbers. Dec 18, 2020
@jangorecki jangorecki added the reshape dcast melt label Dec 19, 2020
@MichaelChirico
Copy link
Member

I did think this was supported, but it never was; checked against versions 1.12.{4,6,8}, 1.13.{0,6} and HEAD.

@MichaelChirico
Copy link
Member

@eliocamp implemented in #4863 if you need it urgently

@MichaelChirico MichaelChirico changed the title Possible regression: dcast doesn't work with complex numbers. dcast doesn't work with complex numbers in value.var. Jan 1, 2021
@eliocamp
Copy link
Contributor Author

eliocamp commented Jan 2, 2021

Thanks!

No urgency. I just used reshape2::dcast() for now.

@mattdowle mattdowle added this to the 1.14.1 milestone Aug 19, 2021
@jangorecki jangorecki modified the milestones: 1.14.9, 1.15.0 Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reshape dcast melt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants