i have data frame looks this:
x1 x3 1: thrl 190..255 2: thra 337..2799 3: thrb 2801..3733 4: thrc 3734..5020 5: yaax 5234..5530 6: yaaa complement(5683..6459) 7: yaaj complement(6529..7959) i struggling separate dataframe 3 columns using .. separator. i've tried other solutions on similar posts such splitstackshape , gsub, none have worked because when delimiters not wildcard values periods.
x1 x2 x3 x4 1: thrl 190 255 f 2: thra 337 2799 f 3: thrb 2801 3733 f 4: thrc 3734 5020 f 5: yaax 5234 5530 f 6: yaaa 5683 6459 r 7: yaaj 6529 7959 r this i'm trying right now
concat.split.multiple(i, "x3", "\\.\\.") any suggestions?
thanks in advance
using dplyr , tidyr:
library(dplyr) library(tidyr) df %>% mutate(x4=ifelse(grepl("complement", x3), "f", "r")) %>% mutate(x3=gsub("[a-z()]", "", x3)) %>% separate(x3, into=c("x2", "x3"), sep="\\.\\.")
Comments
Post a Comment