四开本
我正在创建一个网站,Quarto并希望有一个两列布局,这样我就可以很好地并排显示文本。streamlit您可以使用它columns来获得两列布局。以下是如何布局的示例代码:
---
title: "Two columns layout Quarto"
format:
html:
code-fold: true
engine: knitr
---
I would like to have text here and here
Sentence becomes longer, it should automatically stay in their column More text
Run Code Online (Sandbox Code Playgroud)
输出:
正如您所看到的,文本被组合成一个句子,而我希望将其分开,就像两列布局一样。所以我想知道这是否可能Quarto?
流线型
这是一个例子streamlit:
# Package
import streamlit as st
# Function with columns
def txt(a, b):
col1, col2 = st.columns([7,2])
with col1:
st.markdown(a)
with col2:
st.markdown(b)
# Example
st.write('# Example in Streamlit')
txt('I …Run Code Online (Sandbox Code Playgroud) 我有以下向量input:
input <- c(1,2,1,NA,3,2,NA,1,5,6,NA,2,2)
[1] 1 2 1 NA 3 2 NA 1 5 6 NA 2 2
Run Code Online (Sandbox Code Playgroud)
我想按每个 NA 将这个向量分成多个向量。所以期望的输出应该是这样的:
> output
[[1]]
[1] 1 2 1
[[2]]
[1] 3 2
[[3]]
[1] 1 5 6
[[4]]
[1] 2 2
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,每次 aNA出现时,它都会分裂成一个新的向量。所以我想知道是否有人知道如何将一个向量分割NA成多个向量?
我有以下名为 df 的示例数据框(dput如下):
group date indicator
1 A 2022-11-01 01:00:00 FALSE
2 A 2022-11-01 03:00:00 FALSE
3 A 2022-11-01 04:00:00 TRUE
4 A 2022-11-01 05:00:00 FALSE
5 A 2022-11-01 06:00:00 TRUE
6 A 2022-11-01 07:00:00 FALSE
7 A 2022-11-01 10:00:00 FALSE
8 A 2022-11-01 12:00:00 FALSE
9 B 2022-11-01 01:00:00 FALSE
10 B 2022-11-01 02:00:00 FALSE
11 B 2022-11-01 03:00:00 FALSE
12 B 2022-11-01 06:00:00 TRUE
13 B 2022-11-01 07:00:00 FALSE
14 B 2022-11-01 08:00:00 FALSE
15 B …Run Code Online (Sandbox Code Playgroud) 我有以下数据框 df 和列表 l (dput如下):
> df
group value
1 A 1
2 B 2
3 C 3
> l
$A
[1] 999
$B
[1] 55
Run Code Online (Sandbox Code Playgroud)
我想根据列表中的名称与数据帧的组变量将列表的值连接到数据帧,并将其称为“value_l”。预期输出应如下所示:
group value value_l
1 A 1 999
2 B 2 55
3 C 3 NA
Run Code Online (Sandbox Code Playgroud)
所以我想知道是否有人知道如何根据他们的名字将列表加入到数据框?
dputdf 和 l:
df <- structure(list(group = c("A", "B", "C"), value = c(1, 2, 3)), class = "data.frame", row.names = c(NA,
-3L))
l <- list(A = 999, B = 55)
Run Code Online (Sandbox Code Playgroud) 我想创建一个下拉菜单来Quarto显示多个绘图。这R Markdown真的很简单,每个图都使用# Dropdown menu {.tabset .tabset-dropdown}一些。##这是 R markdown 中的一个可重现的示例:
---
title: "Dropdown menu in Rmarkdown"
date: "2022-08-29"
output: html_document
---
# Dropdown menu {.tabset .tabset-dropdown}
## Plot 1
```{r, echo=FALSE}
plot(1:10, 10:1)
```
## Plot 2
```{r, echo=FALSE}
hist(rnorm(100))
```
## Plot 3
```{r, echo=FALSE}
plot(rnorm(10), rnorm(10))
```
Run Code Online (Sandbox Code Playgroud)
输出:
正如您在输出中看到的,有一个下拉菜单可以单独显示每个图。我在 中找到了一些有关Tabsets 部分的Quarto信息,也许认为使用::: {.tabset-dropdown})可以完成这项工作。我在 a 中尝试了以下代码.tabset-dropdown:
---
title: "Dropdown menu in Quarto"
format: html
---
::: …Run Code Online (Sandbox Code Playgroud) 我想证明文档中文本的合理性Quarto。这意味着它应该自动在单词之间添加文本,以便每行文本的两个边缘都与两个边距对齐。在word-document这将是以下突出显示的符号:
所以我想知道这种方法是否可以在Quarto文档中实现?这是一个可重现的示例:
---
title: "How to justify text in Quarto"
format: html
editor: visual
---
## Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
Quarto is based on Pandoc and uses its variation of markdown as its underlying document syntax. Pandoc markdown is an extended and slightly revised version of John Gruber's Markdown syntax.
Markdown is a plain text format …Run Code Online (Sandbox Code Playgroud) 输入时突然收到以下警告RStudio:
rsession(9608) MallocStackLogging: can't turn off malloc stack logging because it was not enabled.
Run Code Online (Sandbox Code Playgroud)
每次当我在 RStudio 中输入时,都会出现警告,并显示不同的会话,如下所示:
rsession(9608) MallocStackLogging: can't turn off malloc stack logging because it was not enabled.
rsession(9640) MallocStackLogging: can't turn off malloc stack logging because it was not enabled.
rsession(9641) MallocStackLogging: can't turn off malloc stack logging because it was not enabled.
rsession(9652) MallocStackLogging: can't turn off malloc stack logging because it was not enabled.
rsession(9653) MallocStackLogging: can't turn off malloc stack logging because …Run Code Online (Sandbox Code Playgroud) 昨天,我能够将我的针织桌子保存为论文中的图形图像。然而,晚上的某个时候,在下载其他软件包时出现了问题,现在我无法执行代码并收到此错误:
"Could not load c:%5CUsers%5Clehi%5CAppData%5CLocal%5CTemp%5C1%5CRtmpKkDUDx%5Ctable_1A4e045152702b.html
Error in webshot::webshot(file_temp_html, file, ...) :
webshot.js returned failure value: 1"
5.stop("webshot.js returned failure value: ", res)
4.webshot::webshot(file_temp_html, file, ...)
3.save_kable_html(x, file, bs_theme, self_contained, extra_dependencies,
density, ...)
2.save_kable(., file = "table_1A.png")
1.dt %>% kbl(caption = "Table 1: Pregnancy Data") %>% kable_classic(full_width = F,
html_font = "Cambria") %>% save_kable(file = "table_1A.png")
Run Code Online (Sandbox Code Playgroud)
这是可重现的代码:
library(knitr)
library(kableExtra)
library(tidyverse)
library(readxl)
dt <- mtcars[1:5, 1:6]
dt %>%
kbl(caption = "Table 1: Pregnancy Data") %>%
kable_classic(full_width = F, html_font = "Cambria") %>% …Run Code Online (Sandbox Code Playgroud) 爱爱quarto。发育得这么好!再次感谢。我正在使用书籍输出格式,它看起来很棒。不过,我知道它将使用的屏幕尺寸,并且非常希望主要内容 (id= quarto-document-content) 更宽,将目录推到屏幕右侧。我该怎么做?类似的东西(只是近似的例子)
非常感谢!
假设我有一个数据框,可以跟踪行间值的变化。如果该值增加,则变化为“正”。如果该值减少,则变化为“负”。否则,更改列显示“无更改”
df = data.frame(sequence = 1:10, value = c(1,1,1, 2, 2,2,2,1,1,1), change = c('no change', 'no change', 'no change', 'positive', 'no change', 'no change', 'no change', 'negative', 'no change','no change'))
Run Code Online (Sandbox Code Playgroud)
我想创建一个新列来跟踪值列中发生的最后更改的性质。在这种情况下,最终的数据框应如下所示
df = data.frame(sequence = 1:10, value = c(1,1,1, 2, 2,2,2,1,1,1), change = c('no change', 'no change', 'no change', 'positive', 'no change', 'no change', 'no change', 'negative', 'no change','no change')), last_change = c('no change', 'no change', 'no change', 'positive', 'positive', 'positive', 'positive', 'negative', 'negative', 'negative')
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?这是示例数据 - 我的实际数据包含 300 万行。任何帮助将非常感激。