0

I have the following data frame in R and I am trying to split the tags by the vertical bar and and as a new row.

In theory I want to be able to see the different tags by videoid or other variables. I am able to split the tags, but not to link them to the video.

zz  <- data.frame(x$video_id, FOO=x$tags)

but not sure how to continue...

The code below only allows me to separate the tags

tags <- as.character(x$tags)
tags <- strsplit(as.character(x$tags), "\\|")
df <- data.frame(matrix(unlist(tags)))
df <- table(df) #table of df
df <- as.data.frame(df) 

The dataframe

enter image description here

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
  • 1
    Hi @Kenia Cevallos, please find here some help on how to write a good question: https://stackoverflow.com/help/minimal-reproducible-example, i.e. instead of posting a screenshot of your data, please actually include it in the code. – deschen Feb 08 '20 at 12:11
  • 1
    Probably, what you need is `df1 <- tidyr::separate_rows(x, tags, "\\|")` – Ronak Shah Feb 08 '20 at 12:23

0 Answers0