当分隔符是 R 中的竖线 (|) 时将列拆分为行

Split column into rows when the Delimiter is vertical bar ( | ) in R

#Input Table :-

Movie  Genre


Avatar Action|Sci-Fi


#Output Table Required <- 

Movie   Genre

Avatar        Action

Avatar         Sci-Fi

#Consider the name of the dataframe is input

我试过了

output <-separate_rows(input, genre)

结果是:-

Avatar        Action

Avatar         Sci

Avatar    Fi

哪个不是必需的

尝试separate_rows(input, genre, sep='\|')

(sep 是一个正则表达式,所以 | 需要用 \ 转义。)