Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Bug]: `within` doesn't replace the lefthand side of an expression.

オープン
#275 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
r
領域
tooling

調査の方向性

まず within、qenv()、eval_code に関して報告された例を再現し、次に within の実装とそのドキュメントリンクを調べます。左辺がどのように解決されるかを確認し、ドキュメントエントリ @aliases within が欠落していないかを確認します。意図されたミューテーションの動作と ?within の検索がカバーされたら、作業完了とします。

索引モデルが issue の本文から書いたものです。

説明

bug core
What happened?

I wanted to mutate a variable by using as.factor but I found that using this approach doesn't replace the content but creates a new column:

library("teal.code")
var <- "Species"
q <- within(qenv(),
  {
    library("dplyr")
    iris <- iris
    iris2 <- mutate(iris, a = as.factor(a))
  },
  a = as.name(var)
)
setdiff(colnames(q$iris2), colnames(q$iris))
#> [1] "a"

Created on 2025-10-24 with reprex v2.1.1

One workaround is to use the dplyr's walrus := assignment:

library("teal.code")
var <- "Species"
q <- within(qenv(),
  {
    library("dplyr")
    iris <- iris
    iris2 <- mutate(iris, a := as.factor(a))
  },
  a = as.name(var)
)
setdiff(colnames(q$iris2), colnames(q$iris))
#> character(0)

Created on 2025-10-24 with reprex v2.1.1

but this might confuse readers of the code if this end up on the Show R code on teal.
If not a bug perhaps mentioning this on the documentation would be helpful to users.

Also, I realized that within doesn't have the @aliases within so users searching with ?within will not find it (but it is linked from eval_code and qenv).

sessionInfo()

Relevant log output

Code of Conduct
  • I agree to follow this project's Code of Conduct.
Contribution Guidelines
  • I agree to follow this project's Contribution Guidelines.
Security Policy
  • I agree to follow this project's Security Policy.
主要言語
R
スター
12
フォーク
11
平均マージ
8日 15時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

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

insightsengineering/teal.code のほかの issue

insightsengineering/teal.code の issue をすべて見る

似ている issue

R の issue をもっと見る

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

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