Data Explorer: Display column labels for R columns
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:
But you can't see it in Positron.
(originally requested via https://github.com/posit-dev/positron-beta/discussions/113#discussioncomment-9147231)
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.
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.
I think
typeis 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.
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.
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
SDTM datasets (pharma) typically come with labels (xpt and sas7bdat) - RStudio displaying the labels in those cases is very helpful (typically read in with haven).
+1 for column labels! πΊπΌ
Supporting custom labels will likely come at the cost of type, and we'll almost certainly need to expand the height/width of the Column Label to support the extra text at an appropriate size for accessibility.
Option 1: Convert type into a symbol
Option 2: Drop type completely
What if labels were shown upon hovering the column name? We could add a symbol like eg β somewhere to make it discoverable.
I would love to see both type and custom labels! They are each an important part of my day-to-day data analysis and communication workflow.
Of the two options presented I lean towards Option 1 with both type and custom labels. My ideal setup though, would be an Option 3 with taller Column Labels that could allow type to have its own line rather than being displayed as a symbol. In Option 3 users would also have the option to toggle custom labels on or off in global settings. π
A blog post here about why these are important: https://www.pipinghotdata.com/posts/2022-09-13-the-case-for-variable-labels-in-r/
A blog post here about why these are important: https://www.pipinghotdata.com/posts/2022-09-13-the-case-for-variable-labels-in-r/
Thanks for mentioning my blog post! I think I make a stronger case for it in my posit conf talk "Context is King." π The TL; DR is that being able to view column labels is an empowering and effective way for users to get up to speed with the nuances of what variables actually mean.
Requested again in https://github.com/posit-dev/positron/issues/5288.
It would be straightforward to add a column_schema.label field in the backend protocol, if we can agree on how to display this in the front end?
Brought up again in https://github.com/posit-dev/positron/discussions/9173
I'm going to take a crack at this, will post PR for discussion
Take a look at the video in #9179, feedback welcome! With these changes, the label is shown if present, otherwise the type, and I added a tooltip that shows type and label (or just type if there is no label). To get both the type and label displaying would be some CSS engineering, and may have diminishing returns if it crowds an already rather tight UI
The PR merged shows the column labels in tooltips which is helpful. If we want to have them visible at a glance, then we'll have to do some more design / CSS engineering work, so I would suggest we resolve this issue and relegate future design work to a follow up issue. Feedback welcome!
Verified Fixed
Positron Version(s) : 2025.10.0-95
OS Version : OSX
Test scenario(s)
Label visible in tooltip.
Link(s) to TestRail test cases run or created: