A tidyverse-ish solution would be
library(dplyr)
library(tidyr)
library(tibble)
# max cols to split values into
seps<-max(stringr::str_count(unlist(d1),"[/|]"))+1
d1 %>% pivot_longer(S1:S5, names_to="S") %>%
mutate(value=na_if(value,"w")) %>% separate(value,"[/|]",
into=LETTERS[1:seps], fill=
Thank you for the reprex. However your specification was too vague for me
to know exactly what your data are like, so I tried to assume the most
general possibility, with the consequence that I may be giving you an
answer to the wrong question. Hopefully, you can adjust as needed to get
what you wa
Hello,
I am trying to convert a df (given below as d1) into df2 (given below as
res).
I tried using loops for each row. I cannot get it right. Moreover the df
is 25 x 500 in dimension and I cannot get it to work.
Could anyone help me here please.
Thanks.
Adrian.
d1 <-
structure(list(S1 =
3 matches
Mail list logo