看板 R_Language 關於我們 聯絡資訊
try if this function works!! yeild <- function(pdt="Product1",month="Jan",volume=year,output_name="Product1_Jan.csv"){ output <- matrix(0,sum(sapply(year,nrow)),10) for(k in 1:10){ tmpdata <- year[[k]] output[1:sum(tmpdata$Month==month),k] <- tmpdata[which(tmpdata$Month==month),which(colnames(tmpdata)==pdt)] } output <- output[rowSums(output)>0,] colnames(output) <- c(paste("year0",1:9,sep=""),"year10") if( is.null(output_name) ){ output_name <- paste(pdt,"_",month,".csv",sep="") } write.csv(output,file=output_name) } yeild() test <- read.csv("Product1_Jan.csv") test -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.73.70.8
peiwinds:thanks 10/28 17:03