Jamovi计算新变量总计,因为Sumif Cols具有文本?

发布于 2025-01-31 02:45:56 字数 113 浏览 2 评论 0原文

在贾莫维工作。我有10 cols col1至Col10具有文字或空白。我想计算一个新的变量total_col,它仅计算了多少个COL包含文本。这是Sumif吗?在Jamovi Compecute面板中会是什么样?

working in jamovi. I have 10 cols col1 through col10 that either have text or are blank. I want to compute a new variable total_col that simply counts how many cols contain text. Is this a sumif? what would it look like in the jamovi compute panel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜是你 2025-02-07 02:45:56

jamovi模块 rj 允许您执行R代码。以下代码将返回可以包含文本( targe factor )的A class 的列数):

sum(sapply(iris, ## replace "iris" with the name of your data set
           function(VAR) class(VAR) %in% c("character", "factor")))

请注意,在R中,类是固定了数据框的每列,因此所有行的 can Can 包含文本的单元格数将相同。如果您想在单独的列中使用这些相同的条目,则应该 *做 *:

iris$cellcount_text <- sum(sapply(iris, ## replace "iris" as above
           function(VAR) class(VAR) %in% c("character", "factor")))

*未测试,只发现有一个用于使用R代码并提供R代码的Jamovi模块(希望您可以使用命名您将它们保存在下面)。

The Jamovi module Rj allows you to execute R code. The following code will return the number of columns with a class that can contain text (character and factor):

sum(sapply(iris, ## replace "iris" with the name of your data set
           function(VAR) class(VAR) %in% c("character", "factor")))

Note that in R the class is fixed per column of a dataframe, so the number of cells which can contain text will be the same for all rows. If you want to have these identical entries in a separate column though, this should* do:

iris$cellcount_text <- sum(sapply(iris, ## replace "iris" as above
           function(VAR) class(VAR) %in% c("character", "factor")))

* Not tested, only found that there's a Jamovi module for using R code and supplied the R code (hoping that you can address the underlying data with the name you saved them under).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文