Skip to content

Arrays of certain dimension returned from .() do not preserve names as expected #5367

@ccampbell1987

Description

@ccampbell1987

Hello,
I could not find anything related to this in NEWS. I feel that in the case of an array or matrix of a compatible dimension (e.g. nx1 or 1x1) should behave similarly to a vector and preserve the intended name in .(). Adding ".V1" to the intended name below felt unexpected.

Thanks,
Christopher

# Minimal reproducible example; please be sure to set verbose=TRUE where possible!

library(data.table)
DT <- data.table(Counts = c(10, 20), 
                 Severity = c(1,2))

DT[,.(Severity %*% Counts)]
DT[,class(Severity %*% Counts)]
DT[,dim(Severity %*% Counts)]

DT[,.(New_name = Severity %*% Counts)] # name is New_name.V1
DT[,.(New_name = Severity * Counts)] # name is New_name

# Output of sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 21.10

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

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

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

other attached packages:
[1] data.table_1.14.2

loaded via a namespace (and not attached):
[1] compiler_4.0.4 tools_4.0.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions