我bookdown用来创建pdf报告,但我的表都浮动到页面底部,无论有多少空间.看这个例子:
---
title: "test_doc"
author: "Jake Thompson"
date: "6/30/2017"
output:
bookdown::pdf_document2:
toc: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, collapse = TRUE)
library(tidyverse)
```
# Test heading
Let make a data frame and print it in Table \@ref(tab:test-table)
```{r test-table}
data_frame(col_a = seq_len(5), col_b = rnorm(5), col_c = runif(5)) %>%
knitr::kable(caption = "This is a test")
```
Run Code Online (Sandbox Code Playgroud)
生成的pdf如下所示:

为什么表格会在页面底部显示?有没有办法防止这种行为?
在我的报告中,我引用了AERA,APA和NCME的教育和心理测试标准.
@Book{standards,
title = {{Standards for Educational and Psychological Testing}},
author = {{American Educational Research Association} and {American Psychological Association} and {National Council on Measurement in Education}},
shortauthor = {AERA},
publisher = {American Educational Research Association},
address = {Washington, DC},
year = {2014}
}
Run Code Online (Sandbox Code Playgroud)
根据APA样式指南第6版,应该使用可识别的创作组织缩写.我第一次在文中引用这本书,它应该是这样的:
这里有一些填充文本(美国教育研究协会[AERA],美国心理学会和国家教育测量委员会,2014年).这里有一些填充文本(AERA et al.,2014).
但是,我的引用目前显示如下:
这里有一些填充文本(美国教育研究协会,美国心理学会和国家教育测量委员会,2014年).这里有一些填充文本(American Educational Research Association et al.,2014).
有没有办法在预订中实施这些引用?这里有一个最低限度可重复的例子:https://github.com/wjakethompson/bookdown-citations
我目前正在举办我的个人网站(使用创建blogdown和Hugo),使用Netlify wjakethompson.com.这是通过Github存储库部署的.
我现在在一个单独的存储库中有一个bookdown项目,我也想在Netlify上托管,同时利用我为我的个人网站设置的自定义域.
目前,这个bookdown项目正在Netlify subdomin(即wjakethompson-dissertation.netlify.com)上托管.但是,我更喜欢使用我的自定义域,并在wjakethompson.com/disseration(首选)或dissertation.wjakethompson.com上托管第二个repo.这基本上是Github页面所做的(将项目页面托管为用户页面的子页面),但我发现Netlify更容易托管我的个人网页,所以如果可能的话,我想继续使用Netlify.
有没有办法使用Netlify以这种方式主持利用自定义域的第二个网页?
我正在尝试安装gpg-agent,但是我收到一个错误,该公式不存在:
$ brew install gpg-agent
Error: No available formula with the name "gpg-agent"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
Run Code Online (Sandbox Code Playgroud)
但是,似乎这个公式仍然有效:https://formulae.brew.sh/formula/gpg-agent
有没有我错误配置的东西?其他公式为预期工作(例如 …
我正在尝试使用 R Markdown 和{pagedown}包制作简历。
是否可以只在第一页上包含灰色侧边栏?
我已经尝试按照此处所述使用页面标识符。
@page :first {
.aside{
width: var(--sidebar-width);
padding: 0.6in var(--sidebar-horizontal-padding);
font-size: 0.8rem;
float: right;
position: absolute;
right: 0;
}
}
Run Code Online (Sandbox Code Playgroud)
我希望定义.aside内部:first会使灰色的旁栏只出现在第一页上,但没有运气。有什么建议么?
一个最小的例子在这里: https: //github.com/wjakethompson/cv-test
我生成 1 和 0 的数据帧如下:
library(tidyverse)
library(glue)
num_var <- 3
rep(list(c(0L, 1L)), num_var) %>%
set_names(glue("var_{seq_len(num_var)}")) %>%
expand.grid() %>%
mutate(total = rowSums(.)) %>%
select(total, everything()) %>%
arrange(total, desc(var_1, var_2, var_3))
#> total var_1 var_2 var_3
#> 1 0 0 0 0
#> 2 1 1 0 0
#> 3 1 0 1 0
#> 4 1 0 0 1
#> 5 2 1 1 0
#> 6 2 1 0 1
#> 7 2 0 1 1
#> 8 3 1 …Run Code Online (Sandbox Code Playgroud) 我正在color为多面直方图添加美感。在下面的 reprex 中,没有颜色美感,直方图仅显示该方面级别内的数据。但是,在color定义的情况下,添加了一个基线,该基线将拉伸范围扩展为包括所有方面的数据范围。有没有办法让这种情况不发生?
我正在寻找类似于geom_densitywith 的东西trim = TRUE,但似乎没有修剪选项geom_histogram。
library(tidyverse)
data <- tibble(a = rchisq(1000, df = 3),
b = rchisq(1000, df = 1),
c = rchisq(1000, df = 10)) %>%
gather()
ggplot(data, aes(x = value)) +
geom_histogram() +
facet_wrap(~ key, ncol = 1)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Run Code Online (Sandbox Code Playgroud)

ggplot(data, aes(x = value)) +
geom_histogram(color = "red") +
facet_wrap(~ key, ncol = 1)
#> `stat_bin()` using …Run Code Online (Sandbox Code Playgroud) 我试图用来mutate_if根据变量名执行计算.例如,如果变量名包含"demo"则计算均值,如果名称包含"meas",则计算中位数:
library(tidyverse)
library(stringr)
exm_data <- data_frame(
group = sample(letters[1:5], size = 50, replace = TRUE),
demo_age = rnorm(50),
demo_height = runif(50, min = 48, max = 80),
meas_score1 = rnorm(50),
meas_score2 = rnorm(50)
)
exm_data
#> # A tibble: 50 x 5
#> group demo_age demo_height meas_score1 meas_score2
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 a -1.46539563 58.22435 -0.760692567 0.1077901
#> 2 b 1.90983770 56.57976 0.262933462 -1.0186600
#> 3 c 0.58502114 66.26322 2.283491647 0.3215542
#> 4 b …Run Code Online (Sandbox Code Playgroud) ex_data在下面的示例中,我有一个数据框,其中列出了参与者ID,组标识符和一些值。然后,我有了第二个数据框,该框指示需要删除的特定观察值(remove_data在下面的示例中)。有没有一种方法可以使用dplyr或其他tidyverse函数过滤掉这些组合?在下面的工作中,我最终会过滤掉指定参与者的所有记录,而不是仅过滤参与者在该特定组中的数据。我可以使用for循环获得所需的输出,我也将其包括在内以作参考。
library(tidyverse)
#> Loading tidyverse: ggplot2
#> Loading tidyverse: tibble
#> Loading tidyverse: tidyr
#> Loading tidyverse: readr
#> Loading tidyverse: purrr
#> Loading tidyverse: dplyr
#> Conflicts with tidy packages ----------------------------------------------
#> filter(): dplyr, stats
#> lag(): dplyr, stats
set.seed(1234)
ex_data <- data_frame(
id = rep(sample(1:100, 10), 2),
group = rep(c("a", "b"), each = 10),
score = rnorm(20)
)
ex_data
#> # A tibble: 20 x 3
#> id group score
#> …Run Code Online (Sandbox Code Playgroud)