This is regarding latest tidyr
release. I am trying pivot_wider
& pivot_longer
function from library(tidyr)
(Update 1.0.0)
I was trying to obtain normal iris dataset when I run below but instead I get nested sort of 3X5 dimension tibble, not sure whats happening (I read https://tidyr.tidyverse.org/articles/pivot.html) but still not sure how to avoid this
library(tidyr)
iris %>% pivot_longer(-Species,values_to = "count") %>%
pivot_wider(names_from = name, values_from = count)
Expected Output: Normal Iris dataset (150 X 5 dimension)
Edit: I read below that if I wrap around unnest() I get expected output. I am not able to understand why to unnest it when we did not nest it anywhere. Any basic help would be appreciated. Want to understand the concept of what went wrong.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…