[Feature Request] Pretty-print named vectors and matrices?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start by locating the existing pretty_print_code() implementation and reviewing how it formats output. Compare it with the named-vector and named-matrix examples, then clarify the desired color treatment and formatting behavior; the work is done when agreed output and coverage for both cases are established.
Written by the indexing model from the issue text.
Description
Hello,
I'd like to please request a function similar to pretty_print_code() to allow the printing of named vectors.
For example, in this snippet
x<-seq(0.001, 0.020, by = 0.001)
names(x) <- paste0("idx", 1:20)
x
#> idx1 idx2 idx3 idx4 idx5 idx6 idx7 idx8 idx9 idx10 idx11 idx12 idx13
#> 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.010 0.011 0.012 0.013
#> idx14 idx15 idx16 idx17 idx18 idx19 idx20
#> 0.014 0.015 0.016 0.017 0.018 0.019 0.020
Created on 2025-12-08 with reprex v2.1.1
I find it quite hard to separate the names of the vector from the vector values itself. A color coded way to differentiate the two would be greatly appreciated.
Edit:
While I'm at it, printing a named matrix would also be greatly appreciated.
Here's an example problem generated using Claude
# Create the matrix with random values
set.seed(123) # For reproducibility
mat <- matrix(rnorm(400, mean = 50, sd = 15), nrow = 20, ncol = 20)
# Create row names
row_names <- paste0("Row_", sprintf("%02d", 1:20))
# Create column names
col_names <- paste0("Col_", sprintf("%02d", 1:20))
# Assign names
rownames(mat) <- row_names
colnames(mat) <- col_names
# Display the matrix
print(mat)
- Dominant language
- R
- Stars
- 730
- Forks
- 95
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from r-lib/cli
-
C function cli_progress_sleep() is used in an example but not documented.Possibly taken @shreyabyte claimed this 50 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
`pb_elapsed` should not show minutes & fractions of secondsPossibly taken @mcol claimed this 405 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
feat: add `.duration` and `.time_ago` inline stylesPossibly taken A pull request linked to this issue is open or already merged. Openfeature
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
inbo/erl-butterflies-2025#26 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
RConsortium/submissions-pilot7-synthetic-data#95 ·
Maintainers usually reply within 1 day
-
betweenOpen
Difficulty 2/5 1-3 hours Newbie friendliness 65/100