I have a column of screen resolutions with observations like 'IPS Panel Retina Display 2560x1600', '1440x900', 'Full HD 1920x1080', 'IPS Panel Full HD 1920x1080', etc. I want to separate them. I tried the gsub function but the result is to exclude the 'x' also and have the result for example 19201080. Can you help me with this?
CodePudding user response:
vec <- c('IPS Panel Retina Display 2560x1600', '1440x900', 'Full HD 1920x1080', 'IPS Panel Full HD 1920x1080')
strcapture("(.*)\\b([0-9] )x([0-9] )\\b(.*)", vec, proto = list(pre = "", x=0L, y=0L, post = ""))
# pre x y post
# 1 IPS Panel Retina Display 2560 1600
# 2 1440 900
# 3 Full HD 1920 1080
# 4 IPS Panel Full HD 1920 1080