rmd转换html怎么换页,Knit2html不是生成MD文件,而是将我引向rmarkdown :: render

我得到这个错误:

> library(knitr)

> knit2html("pa1_template.rmd")

Error in knit2html("pa1_template.rmd") :

It seems you should call rmarkdown::render() instead of knitr::knit2html() because pa1_template.rmd appears to be an R Markdown v2 document.

我只是rmarkdown跑了::渲染(),它创建的HTML文件。但是,我的任务是让我通过knit2html()运行它并创建一个md文件。

当我通过RStudio“Knit HTML”菜单选项运行Rmd文件时,它会创建好HTML文件。

任何指针赞赏。

这里是RMD文件的内容:

## Loading and preprocessing the data

Read the data file in.

```{r readfile}

steps

steps_good

```

Sum the number of steps per day

```{r summarize/day}

steps_day

```

Create a histogram of the results

```{r histogram}

hist(steps_day$steps, main="Frequency of Steps/day", xlab="Steps/Day", border="blue", col="orange")

```

# What is the mean total number of steps taken per day?

Calculate the mean of the steps per day

```{r means_steps/day}

mean_steps

mean_steps

```

Calculate the median of the steps per day

```{r median_steps/day}

med_steps

med_steps

```

#What is the average daily activity pattern?

Get the average steps per 5 minute interval

```{r avg_5_min}

step_5min

```

Plot steps against time interval, averaged across all days

```{r plot_interval}

plot(step_5min$interval,step_5min$steps, type="l", main="steps per time interval",ylab="Steps",xlab="Interval")

```

On average, which interval during the day has the most steps.

```{r max_interval}

step_5min$interval[which.max(step_5min$steps)]

```

#Imputing missing values

How many NAs are there in the original table?

```{r NAs}

steps_na

length(steps_na)

```

Merge 5 minute interval with original steps table

```{r merge}

steps_filled

```

Replace NA values with mean of steps values for that time interval

```{r replace_na}

steps_na

steps_filled$steps.x[steps_na]

```

Create a histogram of the results

```{r new_hist}

steps_day_new

hist(steps_day_new$steps.x, main="Frequency of Steps/day", xlab="Steps/Day", border="blue", col="orange")

```

It looks like the imputing of NA values increases the middle bar (mean/median) height, but other bars seem unchanged.

Calculate the new mean of the steps per day

```{r new_means_steps/day}

mean_steps

mean_steps

```

Calculate the new median of the steps per day

```{r new_median_steps/day}

med_steps

med_steps

```

It looks like the mean did not change, but the median took on the value of the mean, now that some non-integer values were plugged in.

#Are there differences in activity patterns between weekdays and weekends?

Regenerate steps_filled, and flag whether a date is a weekend or a weekday.

Convert resulting column to factor.

```{r fill_weekdays}

steps_filled

steps_filled$steps.x[steps_na]

steps_filled

steps_filled

for(i in 1:nrow(steps_filled)){

if(steps_filled$wkday[i] %in% c("Saturday","Sunday"))

steps_filled$day_type[i]="Weekend"

else

steps_filled$day_type[i]="Weekday"

}

steps_filled$day_type

```

Get average steps per interval and day_type

```{r plot_interva_day_type}

steps_interval_day

```

Plot the weekend and weekday results in a panel plot.

```{r day_type_plot}

weekday_intervals

weekend_intervals

par(mfrow=c(1,2))

plot(weekday_intervals$Group.1,weekday_intervals$x,type="l",xlim=c(0,2400), ylim=c(0,225),main="Weekdays",xlab="Intervals",ylab="Mean Steps/day")

plot(weekend_intervals$Group.1,weekend_intervals$x,type="l",xlim=c(0,2400), ylim=c(0,225),main="Weekends",xlab="Intervals",ylab="")

2016-07-04

David

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值