Spread multiple columns with values by one columne containing key
问题 Input data : > head(iris[c(48:50, 98:100), 3:5]) Petal.Length Petal.Width Species 48 1.4 0.2 setosa 49 1.5 0.2 setosa 50 1.4 0.2 setosa 98 4.3 1.3 versicolor 99 3.0 1.1 versicolor 100 4.1 1.3 versicolor Output data : setosa.Petal.Length versicolor.Petal.Length setosa.Petal.Width versicolor.Petal.Width 1.4 4.3 0.2 1.3 1.5 3.0 0.2 1.1 1.4 4.1 0.2 1.3 using for example : spread( iris%>%mutate(n=row_number()), key=Species, value=Petal.Length:Petal.Width) #or c("Petal.Length", "Petal.Width")`