小编Dan*_*rez的帖子

右 | 将 Cat() 输出分配给变量

我试图删除生成的“\”,因此我运行 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)

string r cat

7
推荐指数
1
解决办法
6323
查看次数

否定 Data.Table 包中的 %like% | 电阻

我正在尝试使用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)

r dplyr data.table

3
推荐指数
2
解决办法
1042
查看次数

将" - "与R中的文本分开

我试图删除" - "之后的所有文本,包括" - ",如"Albany-Schenectady,Allentown-Bethlehem"等.

我尝试使用Gsub,但无法让代码工作.

#What I tried to make work
gsub("(.*)-.*", "\\1",  
Run Code Online (Sandbox Code Playgroud)

r gsub

0
推荐指数
1
解决办法
55
查看次数

标签 统计

r ×3

cat ×1

data.table ×1

dplyr ×1

gsub ×1

string ×1