[R] interval between specific characters in a string...

Micha Silver t@v|b@r @end|ng |rom gm@||@com
Sun Dec 4 10:38:56 CET 2022


On 04/12/2022 10:25, Hadley Wickham wrote:
> On Sun, Dec 4, 2022 at 1:22 PM <avi.e.gross using gmail.com> wrote:
>> This may be a fairly dumb and often asked question about some functions like strsplit()  that return a list of things, often a list of ONE thing that be another list or a vector and needs to be made into something simpler..
>>
>> The examples shown below have used various methods to convert the result to a vector but why is this not a built-in option for such a function to simplify the result either when possible or always?
>>
>> Sure you can subset it with " [[1]]" or use unlist() or as.vector() to coerce it back to a vector. But when you have a very common idiom and a fact that many people waste lots of time figuring out they had a LIST containing a single vector and debug, maybe it would have made sense to have either a sister function like strsplit_v() that returns what is actually wanted or allow strsplit(whatever, output="vector") or something giving the same result.
>>
>> Yes, I understand that when there is a workaround, it just complicates the base, but there could be a package that consistently does things like this to make the use of such functions easier.
> The next version of stringr (currently being processed by CRAN)
> provides str_split_1() for exactly this purpose.


Thanks!

Well appreciated...


>
> Hadley
>
-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918



More information about the R-help mailing list