[Rd] Feature request: Allow comma after last element in a list
Manfred Kooistra
m@n|red@koo|@tr@ @end|ng |rom gm@||@com
Sat May 2 09:24:39 CEST 2026
Thank you all for the suggested workarounds and feedback!
Here is one other easy and practicable workaround:
c(
1,
2,
3,
recursive = FALSE)
Is is not as brief as Gabor Grothendieck's suggested workaround of c(... , NULL), which is also visually easier to parse and logically more intuitive, and which I already have adopted.
For my purposes, my feature request has thus been satisfyingly answered and my problem has been solved.
* * *
[ Below are some additional thoughts not relevant to the discussion. ]
While following the discussion, I realized that in my mind,
c(1,2,3)
is not the same as
c(
1,
2,
3
)
even though they result in the same object. As I use them, the first is a "list", the second is a "table", if with only one column.
When I manually maintain tabular data, I commonly use
read.table(textConnection("
1 A 12.3
2 B 45.6
"), header = ..., colClasses = c(...))
which easily allows me to add, delete, or rearrange rows. Here, the end of line serves to separate the individual data points, and no comma is necessary anywhere. This practice is what lead to my expectation to be able to use c() in the same way.
Understanding how my expectation arose gave me the idea to use
scan(textConnection("
1
2
3
"), what = numeric(), sep = "\n")
as another possible workaround for vectors in which elements need to be easily rearranged.
More information about the R-devel
mailing list