Home:ALL Converter>Convert multiple lines to single line using RStudio text editor

Convert multiple lines to single line using RStudio text editor

Ask Time:2022-03-14T05:56:11         Author:nicholas

Json Formatter

Does the RStudio text editor have a simple automated way to convert this:

c(
"097",
"085",
"041",
"055"
)

to this: c("097", "085", "041", "055")?

There are answers for other text editors (e.g., here), but I'm looking for a solution specific to RStudio.

Author:nicholas,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71461167/convert-multiple-lines-to-single-line-using-rstudio-text-editor
AndrewGB :

As mentioned by @rdelrossi, datapasta is a helpful package for editing and styling text/code. On Mac, once you install the package (also installs as an add-in), then you have access to several keyboard shortcuts. For example, to convert a vector from vertical to horizontal, you could use vector_paste() or use the keyboard shortcut, which is ctrl+alt+shift+v.\n\nYou can read about some of the other functions and shortcuts (e.g., paste as vertical vector) at Typical Datapasta Usage with Rstudio.",
2022-03-13T23:41:27
Gregor Thomas :

RStudio has a find/replace feature. You can replace new line characters \\n with spaces for this effect. Make sure you have the "regex" box checked for it to work.\n",
2022-03-13T22:04:46
jdobres :

Not an automated solution per se, but many people don't know about RStudio's support for multiline cursors. Just hold Alt (Option on Mac) and drag across multiple lines, then press backspace a few times:\n\nAlso very handy for adding commas or closing parentheses to multiple lines at once.",
2022-03-13T22:20:57
rdelrossi :

The multi-line cursor answer from @jdobres is how I'd do it, but you should also be aware of the excellent datapasta package, which can do what you're asking and a whole lot more. A very helpful add-in for RStudio, imo.",
2022-03-13T22:23:20
yy