[Bug]: `within` doesn't replace the lefthand side of an expression.
まだ誰も着手していません。
評価
調査の方向性
まず within、qenv()、eval_code に関して報告された例を再現し、次に within の実装とそのドキュメントリンクを調べます。左辺がどのように解決されるかを確認し、ドキュメントエントリ @aliases within が欠落していないかを確認します。意図されたミューテーションの動作と ?within の検索がカバーされたら、作業完了とします。
索引モデルが issue の本文から書いたものです。
説明
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
- フォーク
- 12
- 平均マージ
- 4日 22時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pharmaverse/teal.code のほかの issue
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
pharmaverse/teal.code#305 ·
-
[Feature Request]: High cyclomatic complexity leds to bad readability対応中かも @llrs-roche が 87 日前に担当しました。 オープンenhancement
難易度 3/5 3〜5日 初心者へのやさしさ 45/100
pharmaverse/teal.code#295 ·
-
core discussion
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
pharmaverse/teal.code#291 · コメント 2 件 · リアクション 1 件 ·
-
This is test issue to test copilot capabilities対応中かも @copilot-swe-agent が 484 日前に担当しました。 オープンbug
pharmaverse/teal.code#266 · リアクション 1 件 · 担当者 1 名 ·
-
core enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
pharmaverse/teal.code#204 ·
pharmaverse/teal.code の issue をすべて見る
似ている issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
Bioconductor/BiocParallel#289 ·
-
automation
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
waldronlab/BugSigDBcuration#2224 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
merliseclyde/BAS#118 ·