[Rd] Feature request: Allow comma after last element in a list

Tim Taylor t|m@t@y|or @end|ng |rom h|ddene|eph@nt@@co@uk
Fri May 1 14:48:22 CEST 2026


I'd rather (as currently) c() and list() error if I forget to enter an element though. Given this thread has also shown:

a) it was a concious change in the R code base;
b) the functionality is covered well in the package space; and
c) IDE's can easily make things more convenient;

I'm not sure the small convenience factor would be worth the change.

People are normally clamouring for R to tighten up behaviour (e.g. your drop=FALSE request) it's interesting to see requests for the opposite.

Best

Tim


On Fri, 1 May 2026, at 7:52 AM, Mossa Merhi Reimert via R-devel wrote:
> Honestly, I think R just needs to add these things. I don't know what 
> the hold out is.
> It seems so odd, not to just move on from this lack of 
> last-element-comma.
>
> `[`(drop=FALSE) should also be adopted.
>
> Why can't R have these things? CRAN has no package versioning at all. 
> All CRAN packages
> can be adjusted to the change, and it would be all good.
>
>
>
> Sent from Outlook for Mac
> From: R-devel <r-devel-bounces using r-project.org> on behalf of Tomek 
> Gieorgijewski <cybergeorge2020 using gmail.com>
> Date: Thursday, 30 April 2026 at 21.36
> To: Duncan Murdoch <murdoch.duncan using gmail.com>
> Cc: Manfred Kooistra <manfred.kooistra using gmail.com>; 
> r-devel using r-project.org <r-devel using r-project.org>
> Subject: Re: [Rd] Feature request: Allow comma after last element in a 
> list
>
> Thank you for the link - definitely worth trying!
>
> T.
>
> czw., 30 kwi 2026 o 21:24 Duncan Murdoch <murdoch.duncan using gmail.com>
> napisa³(a):
>
>>
>> This is a great suggestion.  BTW, I think it would be possible to do
>> this in RStudio as well.  See their Addins page here:
>> https://rstudio.github.io/rstudioaddins/ .
>>
>> Duncan Murdoch
>>
>> On 2026-04-30 1:44 p.m., Tomek Gieorgijewski wrote:
>> > Hi Manfred!
>> >
>> > As I can see that you already maintain the habit to have one element per
>> > line,
>> > I would like to propose that you incorporate some editing scripts in your
>> > editor
>> > to help ease your frustration.
>> > I believe trying to change R parser will only add more of that feeling :)
>> > I don't know your editor but if it's vim, I can propose this edit to
>> .vimrc
>> > file:
>> > " ----
>> > function! ListCommas() range
>> >         if a:firstline < a:lastline
>> >             " Add commas at the end from first to second to last line if
>> > there's no comma yet
>> >             execute a:firstline . "," . (a:lastline - 1) . 's/[^,]$/&,/e'
>> >         endif
>> >          " Delete comma from last line (if matched)
>> >         execute a:lastline . 's/,$//e'
>> >     endfunction
>> >
>> >     vnoremap <leader>, :call ListCommas()<CR>
>> > " ---
>> >
>> > So, now if you rerun vim on your file you can swap, add, delete lines
>> from
>> > the list as you wish,
>> > and at the end you can highlight all elements lines of your list in
>> visual
>> > mode and execute ListCommas
>> > function on those lines with <leader>, shortcut.
>> >
>> > Of course only if you maintain your structure of element per line and
>> > trailing parenthesis at a seperate line.
>> >
>> > I'm sure VS Code, Emacs and some other editors have similar abilities to
>> > help you.
>> > Unfortunately I don't know of any such possibility in RStudio.
>> >
>> > regards,
>> > Tomek.
>> >
>> > pt., 24 kwi 2026 o 13:35 Manfred Kooistra <manfred.kooistra using gmail.com>
>> > napisa³(a):
>> >
>> >> I've always been irritated that R doesn't allow a comma after the last
>> >> element in a "list":
>> >>
>> >>> a <- c(
>> >> +     1,
>> >> +     2,
>> >> +     3
>> >> + )
>> >>> a
>> >> [1] 1 2 3
>> >>> b <- c(
>> >> +     1,
>> >> +     2,
>> >> +     3,
>> >> + )
>> >> Error in c(1, 2, 3, ) : argument 4 is empty
>> >>
>> >> This makes updating lists unnecessarily cumbersome, which I find I
>> >> frequently do, either when I test code and want to run it with lists of
>> >> varying elements or varying orders of elements or when I maintain lists
>> >> manually over time and have to add or delete elements from them.
>> >>
>> >> Is there a reason for this behavior in R and might it not be a good idea
>> >> to change it?
>> >> ______________________________________________
>> >> R-devel using r-project.org mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-devel
>> >>
>> >
>> >       [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-devel using r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> 	[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list