全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件
3342 1
2013-09-21
> interval_estimate1<-function(x, sigma=-1, alpha=0.05){
+   n<-length(x); xb<-mean(x)
+   if (sigma>=0){
+     tmp<-sigma/sqrt(n)*qnorm(1-alpha/2); df<-n
+   }
+   else{
+     tmp<-sd(x)/sqrt(n)*qt(1-alpha/2,n-1); ff<-n-1
+   }
+   data.frame(mean=xb, df=df, a=xb-tmp, b=xb+tmp)
+ }
> source("interval_estimate1.r")
> X<-c(54,67,68,78,70,66,67,70,65,69)
> interval_estimate1(X)
错误于as.data.frame.default(x[[i]], optional = TRUE) :
  cannot coerce class ""function"" to a data.frame
   



谁能告诉我错在哪里了?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-9-23 00:29:16
Looks like R finds a formula where it expects a data frame. R considers "function" = as.data.frame.default(x[], optional = TRUE)is  not a dataframe. thats why you got the error mssage.

Verify str("function") and check it.

There is online manual here, you can download it
http://cran.r-project.org/doc/manuals/R-intro.pdf


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群