妈蛋,搞到现在才解决
---
title: "main-word"
output: word_document
---
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r, echo=FALSE}
library(rmarkdown)
setwd("C:\\Users\\qzhao\\Documents\\20160418homework")
data<-read.csv("data.csv",stringsAsFactors = FALSE)
for (i in 1:length(unique(data[,2])))
{
name=unique(data[,2])[i]
subdata<-subset(data,data[,2]==name)
#outfile<-paste(name,".docx",sep="")
file=paste("xxx", i, ".docx",sep="")
render("html_report2016.Rmd", output_format="word_document",output_file =file)
}
```
还有子文件html_report