[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
- フォーク
- 11
- 平均マージ
- 8日 15時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
insightsengineering/teal.code のほかの issue
-
Move to Pharmaverse対応中かも @llrs-roche が 37 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
insightsengineering/teal.code#292 ·
-
[Feature Request]: High cyclomatic complexity leds to bad readability対応中かも @llrs-roche が 38 日前に担当しました。 オープンenhancement
難易度 3/5 3〜5日 初心者へのやさしさ 45/100
insightsengineering/teal.code#295 ·
-
core discussion
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
insightsengineering/teal.code#291 · コメント 2 件 · リアクション 1 件 ·
-
bug core
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
insightsengineering/teal.code#272 ·
-
This is test issue to test copilot capabilities対応中かも @copilot-swe-agent が 435 日前に担当しました。 オープンbug
insightsengineering/teal.code#266 · リアクション 1 件 · 担当者 1 名 ·
insightsengineering/teal.code の issue をすべて見る
似ている issue
-
enhancement good first issue help wanted
難易度 2/5 半日 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
question
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
Breaking 🏴☠️ Consistency :green_apple: :apple:
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
easystats/bayestestR#789 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
stan-dev/priorsense#150 ·