Here is the dataset.
library(data.table)
x <- structure(list(id = c("A", "B" ),
segment_stemming = c("[('Brownie', 'Noun'), ('From', 'Josa'), ('Pi', 'Noun')]",
"[('Dung-caroon-gye', 'Noun'), ('in', 'Josa'), ('innovation', 'Noun')]" )),
row.names = c(NA, -2L),
class = c("data.table", "data.frame" ))
x
# id segment_stemming
# 1: A [('Brownie', 'Noun'), ('From', 'Josa'), ('Pi', 'Noun')]
# 2: B [('Dung-caroon-gye', 'Noun'), ('in', 'Josa'), ('innovation', 'Noun')]
I would like to split the tuple into rows. Here is my expected outcome.
id segment_stemming
A ('Brownie', 'Noun')
A ('From', 'Josa')
A ('Pi', 'Noun')
B ('Dung-caroon-gye', 'Noun')
B ('in', 'Josa')
B ('innovation', 'Noun')
I've searched the tuple format using R but cannot find out any clue to make the outcome.
"()"
?('Brownie', 'Noun')
instead of'Brownie', 'Noun'
– Fate