posit-dev / positron

Positron, a next-generation data science IDE
Other
1.95k stars 59 forks source link

Data Explorer: Display column labels for R columns #2971

Open jmcphers opened 2 months ago

jmcphers commented 2 months ago

You can add a label attribute to columns in an R data frame. This is helpful to provide a description of the column that's more verbose than the name you use in code.

df_test <- data.frame(x = 1)
attr(df_test$x, "label") <- "x label"
View(df_test)

In RStudio, this name gets displayed in column header:

image

But you can't see it in Positron.

image

(originally requested via https://github.com/posit-dev/positron-beta/discussions/113#discussioncomment-9147231)

jthomasmock commented 2 months ago

Putting this into the future, we've prioritized column-type over custom labels. I would like to see if others are interested in this. Perhaps we can mockup using labels as an alternative OR how labels + type would work.

One thought we had internally was we could probably replace the column type with the custom variable label from the dataframe.

jsonbecker commented 1 month ago

I think type is important, universal, and should be always present.

I sort of think of labels as an anti-pattern, personally, encouraging the maintenance of non-human readable variable names.

jthomasmock commented 1 month ago

I think type is important, universal, and should be always present.

I sort of think of labels as an anti-pattern, personally, encouraging the maintenance of non-human readable variable names.

Yes, understood! There's also some inconsistency with them round-tripping across various dataframe implementations.

strengejacke commented 4 weeks ago

If I see right, currently types are shown in the left column. So there would be additionally place for labels, similar to RStudio, and then you have both types and labels.

dfalbel commented 3 weeks ago

Also mentioned here: https://github.com/posit-dev/positron/discussions/3773#discussion-6886419 and here https://github.com/posit-dev/positron/discussions/3686#discussion-6872791