Is it possible to use spread on multiple columns in tidyr similar to dcast?
问题 I have the following dummy data: library(dplyr) library(tidyr) library(reshape2) dt <- expand.grid(Year = 1990:2014, Product=LETTERS[1:8], Country = paste0(LETTERS, \"I\")) %>% select(Product, Country, Year) dt$value <- rnorm(nrow(dt)) I pick two product-country combinations sdt <- dt %>% filter((Product == \"A\" & Country == \"AI\") | (Product == \"B\" & Country ==\"EI\")) and I want to see the values side by side for each combination. I can do this with dcast : sdt %>% dcast(Year ~ Product