我有这段代码:
ChiSq_Variance_test=function(critical_Chi_score,critical_Chi_square){
alfa=0.01;
n=120;
s_square=169;
sigma_square=225;
critical_Chi_square=qchisq(alfa,s-1);
Chi_square_score=(n-1)*s_square/sigma_square;
print(critical_Chi_square);
print(Chi_square_score);
}ChiSq_Variance_test(6)
它给了我这个错误:
错误:意外符号:"在此处输入代码} ChiSq_Variance_test"
如果您知道解决方案,请帮助我!谢谢你的时间!
答案 0 :(得分:0)
在R中,为了在同一行上放置两条指令,您应该使用这样的分号:n=120 ; b= 120
。但是,在一行的末尾,您不需要分号
您的代码应该是这样的:
ChiSq_Variance_test=function(critical_Chi_score,critical_Chi_square){
alfa=0.01
n=120
s_square=169
sigma_square=225
critical_Chi_square=qchisq(alfa,s-1)
Chi_square_score=(n-1)*s_square/sigma_square
print(critical_Chi_square)
print(Chi_square_score)
}
ChiSq_Variance_test(6)
或者像这样:
ChiSq_Variance_test=function(critical_Chi_score,critical_Chi_square){
alfa=0.01
n=120
s_square=169
sigma_square=225
critical_Chi_square=qchisq(alfa,s-1)
Chi_square_score=(n-1)*s_square/sigma_square
print(critical_Chi_square)
print(Chi_square_score)
} ; ChiSq_Variance_test(6)