I want to create new column in R and extract informations from other column, which have 6 letters and also start sentence in row.enter image description here
Do you have a idea, how should I do this?
Thank you for any information.
I tried use seperate function, but it didn't work.
CodePudding user response:
You can solve this by using strsplit and sapply functions:
Seqofviruses$ID <- sapply(strsplit(Seqofviruses$seq.name," "), `[`, 1)
Seqofviruses$Definition <- sapply(strsplit(Seqofviruses$seq.name," "), `[`, 2)
CodePudding user response:
You can also try alternatively the substr
function as below
Seqofviruses2 <- Seqofviruses %>% mutate(id=substr(seq.name,1,8), desc=substr(seq.name,9))