positron icon indicating copy to clipboard operation
positron copied to clipboard

Add "row names" to Data viewer and extend support to other objects such as xts

Open abrahammbs93 opened this issue 1 year ago • 2 comments

It will be a great addition for packages such as zoo and xts that use data.frames/matrix and leverage row names attributes.

Including a filter / sorting / aggregation may also be great in general for rownames.

So far the Data viewer dont allow any filtering at all.

image

image

abrahammbs93 avatar Jul 22 '24 21:07 abrahammbs93

We currently look for the row.names attribute when querying info for the data explorer:

https://github.com/posit-dev/ark/blob/75de9287cbfc6fd53e2bf7189cb5f0b7d743fcc3/crates/ark/src/data_explorer/r_data_explorer.rs#L1035-L1052

We could special case it to use index when dealing with xts/zoo objects.

To add support for filtering we'd want to make sure xts/zoo objects are treated as numbers here:

https://github.com/posit-dev/ark/blob/1c8817c664c3fa6f50d8e12b8421509dabe3063b/crates/ark/src/data_explorer/r_data_explorer.rs#L1091-L1102

dfalbel avatar Jul 22 '24 21:07 dfalbel

I believe that zoo/xta support would be a great enabler for econometric and financial applications.

Thanks for you answer

abrahammbs93 avatar Jul 22 '24 21:07 abrahammbs93

This came up in discussions here: https://github.com/posit-dev/positron/discussions/4315

juliasilge avatar Aug 13 '24 20:08 juliasilge

We currently look for the row.names attribute when querying info for the data explorer:

https://github.com/posit-dev/ark/blob/75de9287cbfc6fd53e2bf7189cb5f0b7d743fcc3/crates/ark/src/data_explorer/r_data_explorer.rs#L1035-L1052

We could special case it to use index when dealing with xts/zoo objects.

To add support for filtering we'd want to make sure xts/zoo objects are treated as numbers here:

https://github.com/posit-dev/ark/blob/1c8817c664c3fa6f50d8e12b8421509dabe3063b/crates/ark/src/data_explorer/r_data_explorer.rs#L1091-L1102

I have noticed now Positron can't display rownames of matrix. Could you add support of dimnames attribute in the future? Many old packages still depend this as a variable to perform analysis... If explorer can show this, will be greately helpful. Thanks.

The matrix looks like:

> attributes(m)
$dim
[1] 2 3

$dimnames
$dimnames[[1]]
[1] "Row1" "Row2"

$dimnames[[2]]
[1] "Col1" "Col2" "Col3"

But row names can't display.

Image

ZhimingYe avatar Feb 09 '25 04:02 ZhimingYe

That sounds reasonable to me! I think adding support for dimnames should be straigthforward by making sure we also check for dimnames in:

https://github.com/posit-dev/ark/blob/334d8c93fe2456749e48e483caa7283123c23d6d/crates/ark/src/data_explorer/r_data_explorer.rs#L1006

dfalbel avatar Feb 10 '25 10:02 dfalbel

@ZhimingYe I opened a new issue https://github.com/posit-dev/positron/issues/6287 to separate from the original XTS support request.

dfalbel avatar Feb 11 '25 16:02 dfalbel