同上一次所问,不过简略了很多:前面那个帖子可以删了~~~
不过复杂点的大家可以看看前面那个:http://cos.name/cn/topic/108985
这是简略点的。。。
<br />
> dat <- data.frame(Stress=c("CK","CK","CK","Drought","Drought","Drought","Salt","Salt","Salt","Cold","Cold","Cold"),Expression=c(1.9,9.6,7.3,11.4,6.7,7.1,1.1,6.0,6.8,6.6,1.1,1.5))<br />
> temp <- ddply(dat,.(Stress),summarise,<br />
+ avg_expression=mean(Expression),<br />
+ p.value=function(x){<br />
+ return(t.test(x,dat[1:3,2],alternative="two.sided")$p.value)})<br />
Error in output[[var]][rng] <- df[[var]] :<br />
incompatible types (from closure to logical) in subassignment type fix<br />
虽然数据多了的话,每次都要更改function中t.test y值,但总比tapply计算出pvalue,然后再merge到或者cbind至算好的mean数据中要好多了,
但是这个错误是啥意思?我编的程序哪里错了?我想可能是fuction中的x变量类型有误,但是不知道ddply中传递的x是什么类型。。。
谢谢各位大侠~~~[s:18]
</p>