Partial matching of parameters is confusing

オープン
#7,393 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

@cderv がすでに取り組んでいます。

2023年10月31日 から。

評価

この issue はまだ評価されていません。

説明

bug engines-knitr

In Quarto 1.4.451, create the following dashboard with parameters:

---
title: "Sample dashboard"
format: dashboard
engine: knitr
params:
  hello: 1
  mello: "a character"
---

This should print out the value of `params$hello`: `{r} params$hello`.

This should print out the value of `params$mello`: `{r} params$mello`.

This shouldn't work because it's looking for a parameter that doesn't exist, `params$jello`: `{r} params$jello`.

This also shouldn't work because it's looking for a parameter that doesn't exist, `params$m`, but it does partial matching to `params$mello`, and the document renders: `{r} params$m`

It works, but I think it would be better if partial matching wasn't enabled by default for parameters.

Screenshot 2023-10-29 at 2 44 29 AM

Then add the following and re-render:

This doesn't work because it's doing partial matching and then failing when adding a number to a character `params$m + 2`: `{r} params$m + 2`.

You get the following error:

Quitting from lines 2-18 (untitled.qmd)
Error in `params$m + 2`:
! non-numeric argument to binary operator
Backtrace:
 1. .QuartoInlineRender(params$m + 2)
                                                                                          
Execution halted

It makes sense why this happens, but again, not doing partial matching by default would be less confusing.

Additionally, if I set partial matching to warn in the YAML of my document, e.g.,

knitr:
    opts_chunk:
      R.options:
        warnPartialMatchDollar: true

the first example with partial matching still runs, which was even more surprising to me.

主要言語
JavaScript
スター
6k
フォーク
458
平均マージ
1日 9時間
マージ済み PR(30日)
41

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quarto-dev/quarto-cli のほかの issue

quarto-dev/quarto-cli の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。