[R] how to add comma to string vector?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Fri Jun 10 14:09:12 CEST 2022


Thank you.
```
raws <- c("field_1", "field_2",  "field_3")
paste0("['", paste0(raws, collapse="', '"), "']")
```
gave the most fitting option...

On Fri, Jun 10, 2022 at 12:31 PM Rasmus Liland <jral using posteo.no> wrote:
>
> Hello ...
>
> raws <- c("field_1", "field_2",  "field_3")
> paste0("['", paste0(raws, collapse="', '"), "']")
>
> rasmus using eightforty ~ % python
> Python 3.10.5 (main, Jun  6 2022, 18:49:26) [GCC 12.1.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> ['field_1', 'field_2', 'field_3']
> ['field_1', 'field_2', 'field_3']
>
> ?
>
> R



-- 
Best regards,
Luigi



More information about the R-help mailing list