我正在尝试将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 ) # untestedThe 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.
更多推荐
发布评论