我现在有一个样本,然后我对它其中的几列求了均值,现在有多个样本,我怎么写语句把他们都导进去然后对所有样本都进行同样的计算呢?
dazhongdianping<-function(path){
path<-"C:/Users/lenovo/Documents/Tencent Files/503646253/FileRecv/JR/mydata"
mydata <- dir(path)
filePath <- sapply(mydata, function(x){
paste(path,x,sep='/')})
data <- lapply(filePath, function(x){
read.csv(x, header=T)})
for(i in filePath){
filePath$review.environment<-as.numeric(filePath$review.environment)
filePath$review.service<-as.numeric(filePath$review.service)
filePath$review.taste<-as.numeric(filePath$review.taste)
a<-mean(filePath$review.environment,na.rm=TRUE)
b<-mean(filePath$review.service,na.rm=TRUE)
c<-mean(filePath$review.taste,na.rm=TRUE)
d<-list(a,b,c)
return(d)}
}
这是我写的,但是求不出来均值