ddply()函数位于plyr包,用于对data.frame进行分组统计,与tapply有些类似 准备数据 # 使用stringsAsFactors=F来防止data.frame把向量转为factor apache = data.frame(httpCode=c(200,200,200,404,404,500), time=c(100,111,210,10,10,500), api=c('index','index','logout','show','show','index'), string