[Question]: Making easier to add piped expression to qenv

未关闭
#369 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
r
领域
data

调研方向

首先比较现有的 qenv 和 within API 如何捕获并验证表达式,以及 get_code 如何渲染它们。检查提议的 add_pipe 工作流及其与 teal_data 的交互。完成标准是:可以追加一个未完成的管道,并在多次调用之间继续它,同时将验证延迟到表达式终止之后。

由索引模型根据 Issue 内容生成。

描述

core question
What is your question?

With within is very easy to add a complete expression to qenv.

The pipe has the benefit of reducing the allocation of variables and removing a parameter as is passed implicitly and potentially make code more readable.
R users use/expect pipes (%>% and |> mostly) and often they are created step by step.
If the piped expression is not completed it results in an error, so module developers need to write first the complete expression and then add it to the qenv/teal_data:

library("qenv")
q <- within(qenv(), {
  p <- penguins
})

within(q, {
  p %>% 
    subset(!is.na(sex)) %>% 
})
#> Error: unexpected '}' in:
#> "    subset(!is.na(sex)) %>% 
#> }"

It would be great if there were some method/function to be able to append an incomplete piped expression to be continued.
An idea:

q2 <- add_pipe(q, {p <- p %>% subset(!is.na(sex))}, pipe = "%>%")
cat(get_code(q2))
#> p <- penguins
#> p<- p %>% subset(!is.na(sex)) %>% { }

q3 <- add_pipe(q2, {head()}, pipe = "")
cat(get_code(q3))
#> p <- penguins
#> p <- p %>% subset(!is.na(sex)) %>% head()

Adding an empty character instead of the (default?) pipe could signal the end of the pipeable expression.
Only then the code would be verified.

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
星标
11
派生
10
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pharmaverse/teal.data 的其他 Issue

查看 pharmaverse/teal.data 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。