I have a Text column with thousands of rows of paragraphs, and I want to extract the values of " Capacity > x%
".
(我有一个包含数千行段落的Text列,我想提取“ Capacity > x%
”的值。)
The operation sign can be >,<,=, ~...
I basically need the operation sign and integer value (eg <40%) and place it in a column next to the it, same row. (操作符号可以是>,<,=, ~...
我基本上需要操作符号和整数值(例如<40%),并将其放在它旁边的同一行中。)
I have tried, removing before/after text, gsub, grep
, grepl, string_extract
, etc. None with good results. (我已经尝试过,删除文本, gsub, grep
, grepl, string_extract
等之前/之后。无,效果很好。)
I am not sure if the percentage sign is throwing it or I am just not getting the code structure. (我不确定百分号是否在抛出它,或者我只是没有得到代码结构。)
Appreciate your assistance please. (请感谢您的协助。)
Here are some codes I have tried (aa is the df, TEXT is col name): (这是我尝试过的一些代码(aa是df,TEXT是col名称):)
str_extract(string =aa$TEXT, pattern = perl("(?<=LVEF).*(?=%)"))
gsub(".*[Capacity]([^.]+)[%].*", "\1", aa$TEXT)
genXtract(aa$TEXT, "Capacity", "%")
gsub("%.*$", "%", aa$TEXT)
grep("^Capacity.*%$",aa$TEXT)
ask by Shawn translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…