Aren't these tidyr functions? Newer versions, probably more intuitive, are called pivot_longer() and pivot_wider(). It is nice though how well the tidyverse packages (like dplyr, tidyr, ggplot2, stringr, readr, and others) work together.
I couldn't be sure without looking at the data, but spreading data will introduce NA values in the columns if there isn't a separate row in the long data set for every combination of the levels of the column you are spreading and the columns you aren't spreading. It is not something you can necessarily fix because it means your data set just doesn't contain that information, but you can include the optional argument fill = "fill value" to fill those NAs with 0 or something other than NA in your spread call.
thank you! I was struggling with gather
until this video.
Glad it helped!
Hello from Brazil, thanks for the video!
Aren't these tidyr functions? Newer versions, probably more intuitive, are called pivot_longer() and pivot_wider().
It is nice though how well the tidyverse packages (like dplyr, tidyr, ggplot2, stringr, readr, and others) work together.
The gather()/pivot_longer() and spread()/pivot_wider() are from {tidyr} package, not dplyr.
Thank you.
thankyou so much!
Your missing a link to the next video in your playlist here!
Thanks! I added the end screen link.
Thanks, nice explanation
Thank you, DD.
Thanks
When i use the spread function, some of my column repeat its values and causes some values in the new column to be NA. How do i fix this?
I couldn't be sure without looking at the data, but spreading data will introduce NA values in the columns if there isn't a separate row in the long data set for every combination of the levels of the column you are spreading and the columns you aren't spreading. It is not something you can necessarily fix because it means your data set just doesn't contain that information, but you can include the optional argument fill = "fill value" to fill those NAs with 0 or something other than NA in your spread call.
Is this now called pivot_longer() and pivot_wider()