how to split one row into multiple rows in R
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: for the sake of simplicity suppose I have a column in a data frame like the one below , each row contains multiple countries separated by , df <- data.frame( countries = c( "UK , Spain , Germany , Italy , Netherlands" , "UK , Canada , AUS , China" , "Spain , AUS , Italy , Russia" ) ) This is how data looks like countries 1 UK , Spain , Germany , Italy , Netherland 2 UK , Canada , AUS , China 3 Spain , AUS , Italy , Russia how can we transform this to be something like countries 1 UK 2 Spain 3 Germany 4 Italy 5 Netherlands 6 UK 7 Canada 8 AUS