当定界符为R [duplicate]中的竖线(|)时,将列拆分为行

问题描述 投票:0回答:1
#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

不需要什么

r delimiter tidyr
1个回答
1
投票

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

([sep是一个正则表达式,因此|需要用\\进行转义。)

© www.soinside.com 2019 - 2024. All rights reserved.