Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205491

Split string at separator and create new dataframe

$
0
0

This seems like a basic question so please feel free to point me to another answer but I can't find an answer through my searching.

I have a set of 180,000 rows that looks like this:

df <- c("12hfgog|hcsg9ws|xaw_07cas", "fhjf79", "8xxghk")

I want to split the string at the delimiter "|" and create a new dataframe with the results that looks like this:

df2 <- c("12hfgog","hcsg9ws", "xaw_07cas", "fhjf79", "8xxghk")

I know it involves some combination of strsplit, unlist and unnest but I can't quite get it right. Any help appreciated!


Viewing all articles
Browse latest Browse all 205491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>