我试图删除生成的“\”,因此我运行 cat() 来清除它。但需要将该输出分配给一个变量,以便稍后在 gsubfn 字符串中匹配。
>topheader <-'<div id="editor1" class="shinytinymce shiny-bound-input"
style="resize: none; width: 100%; height: 100%; border-style: none;
background: gainsboro;">'
>topheader
[1] "<div id=\"editor1\" class=\"shinytinymce shiny-bound-input\"
style=\"resize: none; width: 100%; height: 100%; border-style: none;
background: gainsboro;\">"
>cat(topheader)
[1] <div id="editor1" class="shinytinymce shiny-bound-input" style="resize:
none; width: 100%; height: 100%; border-style: none; background:
gainsboro;">
> test<-cat(topheader)
> test
NULL
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用pacakge 中的%like%函数,data.table但反过来。我一直无法找到否定该功能的方法。任何帮助将不胜感激。
宁愿不使用 greplinvert = TRUE选项。尽量保持代码简单。
#Original code to find the match#
library(data.table)
Table1 <- data.table(Table1)
Table1 <-Table1[`Account Name` %like% 'Nike']
Run Code Online (Sandbox Code Playgroud) 我试图删除" - "之后的所有文本,包括" - ",如"Albany-Schenectady,Allentown-Bethlehem"等.
我尝试使用Gsub,但无法让代码工作.
#What I tried to make work
gsub("(.*)-.*", "\\1",
Run Code Online (Sandbox Code Playgroud)