- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个相对简单的用户定义函数来输出交叉表,但不太确定为什么它没有运行。
我的测试数据:
fp_within = structure(list(weight_cat.w1 = structure(c(1L, 2L, 2L, 1L, 1L,
2L, 1L, 1L, 3L, 3L, 3L, 3L, NA, 3L, 3L, 2L, NA, NA, NA, NA), .Label = c("1",
"2", "3"), label = "Weight (Wave 1)", class = c("labelled", "factor"
)), weight_cat.w2 = structure(c(1L, 2L, 2L, 1L, 1L, 2L, 1L, NA,
2L, 3L, 3L, 2L, 1L, 3L, 3L, 2L, 2L, 2L, 3L, 1L), .Label = c("1",
"2", "3"), label = "Weight (Wave 2)", class = c("labelled", "factor"
))), row.names = c(NA, -20L), class = c("tbl_df", "tbl", "data.frame"
))
我的代码:
library(expss)
library(tidyr)
xtable = function(wave1, wave2, name) {
xtab = fp_within %>%
tab_cells(wave1) %>%
tab_cols(wave2) %>%
tab_stat_cases() %>% # tab_stat_cases = counts
tab_pivot() %>%
set_caption(glue("Table showing agreement in {name} across waves (N)"))
return(xtab)
}
xtable(weight_cat.w1, weight_cat.w2, "weight")
这会抛出一个错误...
Error in eval(expr, envir = e, enclos = baseenv()) :
object 'weight_cat.w1' not found
这在函数之外工作,我期待这样的输出:
Table showing agreement in weight across waves (N)
| | | Weight (Wave 2) | | |
| | | 1 | 2 | 3 |
| --------------- | ------------ | --------------- | ---- | ---- |
| Weight (Wave 1) | 1 | 1519 | 309 | 5 |
| | 2 | 300 | 1229 | 299 |
| | 3 | 6 | 278 | 1559 |
| | #Total cases | 1825 | 1816 | 1863 |
最佳答案
参数 weight_cat.w1
和 weight_cat.w2
在到达 tab_*
之前被评估。因为在你的数据集之外没有这样的变量,所以会抛出错误。为避免初步评估,您需要特别注意使用 eval(substitute(...))
:
xtable = function(wave1, wave2, name) {
xtab = eval(substitute({
fp_within %>%
tab_cells(wave1) %>%
tab_cols(wave2) %>%
tab_stat_cases() %>% # tab_stat_cases = counts
tab_pivot()%>%
set_caption(glue("Table showing agreement in {name} across waves (N)"))
}))
return(xtab)
}
关于r - 使用 expss::cro() 编写用户定义的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61688170/
使用 cro stub http test test 创建 stub 服务后,我在 中定义了 TEST_PORT 环境变量.cro.yml : --- id: test cro: 1 name: "t
我已经从 CommaIDE(社区版本 2020.05)运行了一些 cro 微服务而没有出现故障,然后发现我也可以将它们作为 cro 服务本身进行晒太阳。然而,似乎没有任何明显的区别。配置屏幕是相同的,
下面的客户端程序从WebSocket服务器接收消息。 它不发送任何消息。 客户 use v6; use Cro::WebSocket::Client; constant WS-URL = 'ws://
我尝试使用 Cro 创建一个将在 rabbitMQ 中发布消息的 Rest API。我想将我的路线分成不同的模块,并用“包含”组合它们。但我也希望能够在每个模块中共享与 rabbitMQ 的相同连接。
假设我需要在提供一些结果之前检查一些 URI。我可以做这样的事情: sub type-routes { route { get -> Str $type where $type
我在 Windows 7 上运行 Rakudo Star 2019.03.1,Cro 由 zef 安装。关注Getting Started关于 Cro website 的部分,以下应该有效: The
使用“cro sub”创建了一个 websocket 服务器。 写了这个客户: use v6; use Cro::WebSocket::Client; constant WS-PORT = '2000
通过 Zef 安装了 Cro,但无法运行“cro stub”、“cro run”等。 (编辑:Fedora 28,来自 Fedora 的 rakudo) [zv@localhost ~]$ cro s
我正在尝试编写一个相对简单的用户定义函数来输出交叉表,但不太确定为什么它没有运行。 我的测试数据: fp_within = structure(list(weight_cat.w1 = structu
控制台在启动 cro ('cro run') 后显示此消息: ▶ Starting JoanPujol (JoanPujol) 🔌 **Endpoint HTTP will be at http:/
我正在尝试学习 Cro(和 Perl6 同时);) 我的学习应用程序基于 Cro 的文档。我添加了一些确实有效的身份验证,但用户 session 会立即被遗忘。 您可以在 https://gitlab
我想运行 perl6/raku Cro 应用程序作为前端网络服务器后面的服务。 刚跑cro run在段错误和重新启动后不会处理重新启动。 以前使用 perl5 我使用过 FastCGI - 但是 Cr
我正在尝试组合一个 Cro 服务,该服务具有 react/whenever 阻止“在后台”消费数据因此与许多使用 Cro 的 websocket 使用示例不同,这与可以通过浏览器访问的路由无关。 我的
cro run 当目录树中的任何内容发生更改时,停止服务器、重新编译、重新启动服务器。太好了。 但是,在开发客户端 UI 并使用 NPX/yarn/webpack 时,需要执行一个额外步骤来生成 ma
我正在考虑使用 perl6 和 Cro 来构建一个包含文本内容的网站。是否有关于将 Cro 与模板工具包(例如 TT2)和代码示例一起使用的最佳实践/指南供我利用? 最佳答案 你看过 Cro::Web
我正在使用带有天堂标签的数据框(导入数据集时变量已经有值标签)。我需要运行两个变量的许多交叉制表。我正在使用 expss 包中的 cro 函数,因为默认情况下显示值标签,并计算加权交叉表。 但是,我得
我正在寻找一个简单的解决方案来使用 Cro 的基本身份验证机制来保护我的路由。在我的示例中,我希望看到 401 Unauthorized如果您根本不提供任何凭据。如果您提供错误的凭据,我希望看到 40
我正在使用Cro HTTP Authentication/Authorization/Sessions HTTP 路由非常成功。 然后我添加了一条使用 Cro::HTTP::Router::WebSo
当使用带有 HTTP1.1 的 Cro 时,我可以通过主机方法 request.uri.host 访问请求的主机。在 Cro::Uri以及浏览器通过 request.header 发送的 Host 或
我要获取https://translate.google.cn的内容,但是,Cro::HTTP::Client和 HTTP::UserAgent只是卡住了,WWW获取内容,我不知道为什么。 如果我更改
我是一名优秀的程序员,十分优秀!