r中的by()错误:找不到函数“FUN”(by() error in r: could not find function “FUN”)

系统教程 行业动态 更新时间:2024-06-14 16:54:47
r中的by()错误:找不到函数“FUN”(by() error in r: could not find function “FUN”)

我正在尝试将t检验应用于具有24级(扬声器)的因子。 我的目标是根据连续变量,强度差异(intdiff)查看拼写法(2级:jj或L)之间是否存在显着差异。 但是,使用by()函数时,它返回以下错误:

Error in FUN(X[[1L]], ...) : could not find function "FUN"

我产生错误的语法是:

by(data, data$speaker, t.test(intdiff~orthography))

我根据R文档指定了参数,所以我无法弄清楚为什么它不接受我提供的功能。 任何帮助将不胜感激。 如果您需要尝试重现问题,这里是我正在使用的数据集:

https://www.dropbox.com/s/bxb9ebavln1rh3u/SpanishPalatals.csv

提前谢谢了。

I am trying to apply a t-test to a factor with 24 levels (speaker). My goal is to see if there is a significant difference between orthography (2 levels: jj or L) according to the continuous variable, intensity difference (intdiff). However, when using the by() function, it returned the following error:

Error in FUN(X[[1L]], ...) : could not find function "FUN"

My syntax which produced the error was:

by(data, data$speaker, t.test(intdiff~orthography))

I specified the arguments according to the R documentation, so I can't figure out why it's not accepting the function I provided. Any help would be greatly appreciated. In the event you need to try to reproduce the problem, here is the data set with which I am working:

https://www.dropbox.com/s/bxb9ebavln1rh3u/SpanishPalatals.csv

Many thanks in advance.

最满意答案

这: t.test(intdiff~orthography)不是一个函数。 看来您希望拆分数据帧,这样可能会成功:

by(data, data$speaker, function(d){ t.test(d$intdiff ~ d$orthography, data=d)} )

进一步解释: function(d){ t.test(d$intdiff ~ d$orthography)}是一个函数。 或者你可以尝试:

by(data, data$speaker, t.test, form= intdiff ~ orthography ) # untested

第二个版本使用t.test(这是一个函数'name'而不是函数'call'),并且有一个t.test的公式方法。 与参数名称的匹配接受部分名称,因此传递给`.test的数据帧应自动匹配'data'参数。

This: t.test(intdiff~orthography) is not a function. It appears you are expecting by to split a dataframe so this might succeed:

by(data, data$speaker, function(d){ t.test(d$intdiff ~ d$orthography, data=d)} )

To explain further: function(d){ t.test(d$intdiff ~ d$orthography)} is a function. Or you could try:

by(data, data$speaker, t.test, form= intdiff ~ orthography ) # untested

The second version uses t.test (which is a function 'name' rather than a function 'call') and there is a formula method for t.test. The matching with argument names accepts partial names, so the dataframe being passed to`.test should get automatically matched to the 'data' argument.

更多推荐

本文发布于:2023-04-08 12:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/1c1bca745563d90b46fa1ff1833769e1.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   函数   错误   FUN   find

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!