Spread with duplicate identifiers (using tidyverse and %>%) [duplicate]

We can use tidyverse. After grouping by ‘start_end’, ‘id’, create a sequence column ‘ind’ , then spread from ‘long’ to ‘wide’ format library(dplyr) library(tidyr) df %>% group_by(start_end, id) %>% mutate(ind = row_number()) %>% spread(start_end, date) %>% select(start, end) # id start end #* <int> <fctr> <fctr> #1 2 1994-05-01 1996-11-04 #2 4 1979-07-18 NA #3 … Read more

What are the differences between R’s new native pipe `|>` and the magrittr pipe `%>%`?

Another difference between both of them is for the piped in values . can be used as a placeholder in magrittr‘s pipe c(“dogs”, “cats”, “rats”) %>% grepl(“at”, .) #[1] FALSE TRUE TRUE But this is not possible with R’s native pipe. c(“dogs”, “cats”, “rats”) |> grepl(“at”, .) Error in grepl(c(“dogs”, “cats”, “rats”), “at”, .) : … Read more