各位大神好~
第一次进来求助~
最近学习的《R in Action》(R语言实战),第二十二章中,”用R和Markdown创建报告“部分,已经下载了Rstudio并且按照代码清单创建了.Rmd(即以下附文中women.Rmd)文件,然后教材中说使用"rmarkdown"包中的"render"函数生产HTML的报告,这时候R就报错说找不到函数中提到的.Rmd文件。。。
教材作者感觉在这一章都不怎么上心,真是苦,找不到解决办法。。。真心求助~
附:
第一部分(.Rmd文件内容)
---
title: "Regression Report"
output:
html_document: default
word_document: default
---
```{r echo=FALSE,results='hide'}
n <- nrow(women)
fit <- lm(weight~height,data=women)
sfit <- summary(fit)
b <- coefficients(fit)
```
Linear regression was used to model the relationship between weight and height in a sample of `r n`women.The equation **weight=`r b[[1]]`+`r b[[2]]`*height**accountded for `r round(sfit$r.squared,2)`%of the variance in weights.The ANOVA table is given below.
```{r echo=FALSE,results='asis'}
library(xtable)
options(xtable.comment=FALSE)
print(xtable(sfit),type="html",html.table.attributes="border=0")
```
The regression is plotted in the following figure.
```{r echo=FALSE,fig.width=5,fig.height=4}
library(ggplot2)
ggplot(data=women,aes(x=height,y=weight))+geom_point()+geom_smooth(method="lm")
```
第二部分(R中的代码及报错内容)
>library(rmarkdown)
Note: no visible global function definition for 'radixsort'
>
>render("women.Rmd","html_document")
Error in tools::file_path_as_absolute(input) :
file 'women.Rmd' does not exist
此外: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="women.Rmd": 系统找不到指定的文件。
|