felixzhao123 发表于 2017-8-6 14:53 
我用一个公共数据集mpg做例子,供你参考:
##assumption: we want to build a linear model for Time.relative(predictor) and AFP.value (response) by group of class
nested_HCC<-HCC%>%
group_by(ref)%>%
nest()
### create a function to be used for each group of class
linear_Model <- function(df){
lm(AFP.value~Time.relative,data=df)
}
nested_Model <- nested_HCC%>%
mutate(model=map(data,linear_Model))
我运行到这一行的时候报错。。Error in mutate_impl(.data, dots) :
Evaluation error: contrasts can be applied only to factors with 2 or more levels.
此外: There were 50 or more warnings (use warnings() to see the first 50)
大神求解答