[R] split element vector

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Fri Aug 6 16:49:15 CEST 2021


Perfect!
thank you

On Fri, Aug 6, 2021 at 4:17 PM Bill Dunlap <williamwdunlap using gmail.com> wrote:
>
> unlist(strsplit(vect, "\n"))
>
> On Fri, Aug 6, 2021 at 7:13 AM Luigi Marongiu <marongiu.luigi using gmail.com> wrote:
>>
>> Hello,
>> I have a vector that contains some elements with concatenated values, such as:
>> ```
>> > vect
>> [1] "name_1"
>> [2] "name_2"
>> [3] "name_3\nsurname_3"
>> [4] "some other text\netc"
>> ```
>> How can I create a new vector where each component is an element, such as:
>> ```
>> > vect
>> [1] "name_1"
>> [2] "name_2"
>> [3] "name_3"
>> [4] "surname_3"
>> [5] "some other text"
>> [6] "etc"
>> ```
>> I can split the elements on '\n' but how do I transfer these directly
>> on a new vector?
>> Thanks
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.



-- 
Best regards,
Luigi



More information about the R-help mailing list