小编Gon*_*ier的帖子

在 R 中抑制 system() 输出

我想将invisible()函数行为应用于我在脚本中得到的输出,如下所示system("cmd.exe", input = command)。然而,即使使用不可见,输出仍然显示在控制台中。有什么办法可以隐藏它吗?

编辑:我正在curl命令中运行来下载网页,输出是预期的curl 输出。

EDIT2:可重现的示例

url <- "www.google.com"
command <- paste0('curl "', 
                  url,
                  '"',
                  ' -H "Pragma: no-cache" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en-US,en;q=0.9" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" -H "Cache-Control: no-cache" -H "Cookie: uupid69991=eb4c8ec5-1f94-4cf5-957d-e477a778f79c; uupid99993=eb4c8ec5-1f94-4cf5-957d-e477a778f79c; uupid89991=1; uupid79991=Fee_Based_Role; locale=en; uupid99991=1903 x 1012; IVZSESSIONID=CEHrDvYqpDuQ-zwy8YZpWwm1RWZHY3DGq4V7elBfxcH87XFFo-J_^! -175310928; _ga=GA1.2.1974800928.1524362050; _gid=GA1.2.1544243785.1524362050" -H "Connection: keep-alive" --compressed',
                  ' > google.html')

invisible(system("cmd.exe", input …
Run Code Online (Sandbox Code Playgroud)

r

4
推荐指数
1
解决办法
2896
查看次数

R ggplot:如何将点与躲避条对齐?

我想知道如何将 geom_point 点与 geom_bar 躲避条位置对齐。

根据 Year 参数对条形图进行躲避,但无论其 Year 参数如何,所有点都绘制在躲避条形图的中间。

在此处输入图片说明

可重现的代码:

set.seed(42)
dat <- data.frame(Response = rep(paste0("Response",1:4),2),
                  Proportion = round(runif(8),2),
                  Year = c(rep(2017,4),rep(2018,4)))
industries <- data.frame(Response = rep(paste0("Response",1:4),6),
                         Proportion = round(runif(24),2),
                         Year = rep(c(rep(2017,4),rep(2018,4)),3),
                         Cat = rep(paste0("Cat",1:3),c(rep(8,3))))
ggplot(dat, aes(Response, Proportion, label = paste0(Proportion*100,"%"), fill = factor(Year))) + 
  geom_bar(stat = "identity", position = "dodge" ) + 
  geom_point(data = industries, aes(Response, Proportion, fill = factor(Year), col= Cat), size = 3) +
  theme(axis.text.x = element_text(angle = 90)) + 
  scale_y_continuous(labels = scales::percent) + 
  geom_text(position …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

2
推荐指数
1
解决办法
894
查看次数

标签 统计

r ×2

ggplot2 ×1