assign.group <- function(value){
if(value < 0.25){return_value <- "group1"}
else if(value < 0.5){return_value <- "group2" }
else if(value < 0.75){return_value <- "group3" }
else return_value <- "group4"
return_value
}
## 新增欄位並填入值
add.col.group <- function(data){
data$group <- 0
data$group <- sapply(data$avg, assign_group) ##avg即為第八個欄位的名稱
data
}