小编Jan*_*rup的帖子

本地窗口上的gitlab-runner错误

我正在尝试本地生成我正在进行的工作hugo网站.它与gitlab CI一起工作正常.

我安装了docker和gitlab runner服务.

然后在这里使用指南,我想我应该这样做gitlab-runner exec docker pages.但结果是:

[0;33mWARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of upcoming releases[0;m
[0KRunning with gitlab-runner 10.5.0 (80b03db9)
[0;m[0KUsing Docker executor with image rocker/tidyverse:latest ...
[0;m[0KPulling docker image rocker/tidyverse:latest ...
[0;m[0KUsing docker image sha256:f9a62417cb9b800a07695f86027801d8dfa34552c621738a80f5fed649c1bc80 for rocker/tidyverse:latest ...
[0;m[31;1mERROR: Job failed (system failure): Error response from daemon: invalid volume specification: '/host_mnt/c/builds/project-0/Users/jan/Desktop/gits/stanstrup-web:C:\Users\jan\Desktop\gits\stanstrup-web:ro'
[0;m[31;1mFATAL: Error response from daemon: …
Run Code Online (Sandbox Code Playgroud)

windows docker hugo gitlab-ci-runner blogdown

13
推荐指数
1
解决办法
1366
查看次数

DT 中的引文:数据表

我正在做一个 bookdown 项目,其中我们有包含引文的大表。我们同时输出 html 和 pdf。问题是我找不到在表格中呈现引文的方法。

对于 PDF 输出,此乳胶解决方法有效:https : //github.com/haozhu233/kableExtra/issues/214 但是,对于我一直在使用的 html 输出DT:datatable,我无法找到使引用呈现的方法。

有没有办法在表格中获得降价解析的引文?

降价示例:

---
title: "Untitled"
output: html_document
bibliography: ["references.bib"]
---


In text citation [@chambers_2012].


A plan data.frame can render the reference if inserted as text that markdown can parse.

```{r, results='asis'}
library(dplyr)
library(DT)

data_frame(citation = "[@chambers_2012]")

```

But not in a DT.

```{r, results='asis'}
library(dplyr)
library(DT)

data_frame(citation = "[@chambers_2012]") %>% datatable()

```



# bibliography
Run Code Online (Sandbox Code Playgroud)

示例参考.bib

@article{chambers_2012,
title = {A cross-platform toolkit for mass …
Run Code Online (Sandbox Code Playgroud)

r r-markdown dt bookdown

6
推荐指数
1
解决办法
318
查看次数

如何检测裸变量或字符串

我正在尝试编写一个绘图函数,您可以在其中传递裸列名称以选择绘制哪些列.我还想能够指定一个字符串作为颜色.

我发现如果我想将字符串传递给aes_string,我需要使用shQuote.现在我的问题是弄清楚是否传递了一个简单的名字或字符串.我该怎么做?

dat <- data.frame(
    time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")),
    total_bill = c(14.89, 17.23)
)



plot_it <- function(dat, x,y, fill){
    require(rlang)
    require(ggplot2)

    x <- enquo(x)
    y <- enquo(y)
    fill <- enquo(fill)

    xN <- quo_name(x)
    yN <- quo_name(y)
    fillN <- quo_name(fill)

ggplot(data=dat, aes_string(x=xN, y=yN, fill=fillN)) +
    geom_bar(stat="identity")

}
Run Code Online (Sandbox Code Playgroud)

这有效:

plot_it(dat, time, total_bill, time)
Run Code Online (Sandbox Code Playgroud)

这不是:

plot_it(dat, time, total_bill, "grey")
Run Code Online (Sandbox Code Playgroud)

请注意,这需要最新版本的rlang和ggplot2.

r ggplot2 tidyverse

5
推荐指数
1
解决办法
252
查看次数

带有嵌套/子行和模态的数据表

我正在尝试制作一个具有两层嵌套的数据表。第一个用于对行进行分组(https://github.com/rstudio/shiny-examples/issues/9#issuecomment-295018270),第二个应该打开一个模式(R ShinyBS 弹出窗口)。我可以让它单独工作,但第二层嵌套会产生问题。一旦有第二次嵌套,表中的数据就不再显示在折叠组中。

所以到目前为止我所做的至少有一个问题,那就是如何在有多个嵌套时正确显示它。在那之后,我不确定模式当前是否有效。我想知道这些 id 是否不会与现在的方式发生冲突。

任何提示表示赞赏。

# Libraries ---------------------------------------------------------------
library(DT)
library(shiny)
library(shinyBS)
library(shinyjs)

library(tibble)
library(dplyr)
library(tidyr)
library(purrr)


# Funs --------------------------------------------------------------------

# Callback for nested rows
nest_table_callback <- function(nested_columns, not_nested_columns){

    not_nested_columns_str <- not_nested_columns %>% paste(collapse="] + '_' + d[") %>% paste0("d[",.,"]")

    paste0("
            table.column(1).nodes().to$().css({cursor: 'pointer'});

            // Format data object (the nested table) into another table
            var format = function(d) {
              if(d != null){ 
                var result = ('<table id=\"child_' + ",not_nested_columns_str," + '\">').replace('.','_') + '<thead><tr>'
                for (var col …
Run Code Online (Sandbox Code Playgroud)

r datatables shiny shinyjs shinybs

5
推荐指数
0
解决办法
2394
查看次数

来自逻辑矩阵的紧凑字母显示

我想知道是否有办法将比较的逻辑矩阵转换为多重比较测试中使用的字母符号.如在multcomp::cld.

我的数据看起来像这样:

test_data <- data.frame(mean=c(1.48, 1.59, 1.81,1.94),CI_lower=c(1.29,1.38,1.54, 1.62),CI_upper=c(1.56,1.84, 2.3, 2.59))

  mean CI_lower CI_upper
1 1.48     1.29     1.56
2 1.59     1.38     1.84
3 1.81     1.54     2.30
4 1.94     1.62     2.59
Run Code Online (Sandbox Code Playgroud)

我感兴趣的是一种符号,表示哪些条目具有重叠的CI,以获得如下所示的最终结果:

final <- data.frame(mean=c(1.48, 1.59, 1.81,1.94),CI_lower=c(1.29, 1.38,1.54, 1.62),CI_upper=c(1.56,1.84, 2.3, 2.59),letters = c("a","ab","ab","b"))

  mean CI_lower CI_upper letters
1 1.48     1.29     1.56       a
2 1.59     1.38     1.84      ab
3 1.81     1.54     2.30      ab
4 1.94     1.62     2.59       b
Run Code Online (Sandbox Code Playgroud)

我做了一个可怜的尝试,就像这样:

same <- outer(test_data$CI_lower, test_data$CI_upper,"-")
same <- same<0
same <- lower.tri(same, diag = …
Run Code Online (Sandbox Code Playgroud)

r

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

按名称提取节点

我正在尝试使用 xml2 解析 XML 文件。但是我终生无法通过指定名称来弄清楚如何做到这一点。

这有效:

library(xml2)
library(dplyr)

xml <- read_xml(file)
Run Code Online (Sandbox Code Playgroud)

-->

> xml
{xml_document}
<indexedmzML schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.2_idx.xsd" xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
[1] <mzML xmlns="http://psi.hupo.org/ms/mzml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/ms/mzml  ...
[2] <indexList count="2">\n  <index name="spectrum">\n    <offset idRef="scanId=3027">15181</offset>\n    <offset idRef="scanId=3524">30052</offset> ...
[3] <indexListOffset>73363063</indexListOffset>
[4] <fileChecksum>b8f69d6276d9c4929e74416bc9e3446a173d1894</fileChecksum>
Run Code Online (Sandbox Code Playgroud)

我可以一步一步地和使用 xpath 按位置提取:

xml_child(xml, 1) %>% xml_child(7) %>% xml_attr("startTimeStamp")
Run Code Online (Sandbox Code Playgroud)

_

xml_child(xml, "/*[1]/*[7]") %>% xml_attr("startTimeStamp")
Run Code Online (Sandbox Code Playgroud)



但是,我按名称选择的尝试失败了。

> xml_child(xml, "indexedmzML")
{xml_missing}
<NA>
> xml_child(xml, "mzML")
{xml_missing}
<NA>
Run Code Online (Sandbox Code Playgroud)

> xml_child(xml, "/indexedmzML")
{xml_missing}
<NA>
> xml_child(xml, "/mzML")
{xml_missing}
<NA>
Run Code Online (Sandbox Code Playgroud)

> xml_child(xml, "/mzML/run") …
Run Code Online (Sandbox Code Playgroud)

r xml2

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