Markdown在第一个块之后不编译。我能够单独运行所有块,然后一次运行它们。尝试编织到HTML文档时,markdown不会在第一个块上立即编译并停止。没有错误,没有警告等,然后停止。
我尝试过eval = False,它什么也没输出,我删除了代码的几部分,发现它是HTML表刮擦的一部分。但是,当我运行该块时可以使用。
---
title: "Harry Potter Cast"
author: "Ben Tanaka"
date: "5/29/2019"
output:
html_document:
keep_md: yes
---
```{r setup, echo=FALSE, include=FALSE, warning=FALSE,message =FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(xml2)
library(rvest)
library(stringr)
library(tibble)
library(data.table)
library(knitr)
library(kableExtra)
library(dplyr)
library(tidyr)
library(ggplot2)
```
# *Harry Potter Cast*
```{r Harry_Potter}
potter_url <- 'https://www.imdb.com/title/tt1201607/fullcredits?ref_=tt_ql_1'
potter_scrape <- read_html(potter_url)
potter_cast_uf <- {potter_scrape %>% html_nodes("table") %>% .[[3]] %>% html_table()}
potter_cast_df <- potter_cast_uf[,c(2,4)]
setnames(potter_cast_df,old=c("X2","X4"),new=c("Actor","Character"))
str_replace_all(potter_cast_df$Actor, '[\r\n]' , '')
str_replace_all(potter_cast_df$Character, '[\r\n]' , '')
potter_cast_tbl <- as_tibble(potter_cast_df)
{potter_cast_tbl %>% mutate_all(funs(str_replace_all(.,'[\r\n]' , '')))}
potter_cast_tbl <- potter_cast_tbl[-1,]
potter_cast_tbl <- potter_cast_tbl[-92,]
{potter_cast_tbl %>% mutate_all(funs(str_replace_all(.,'Griphook / \n Professor Filius Flitwick' , 'Griphook / Professor Filius Flitwick')))}
{potter_cast_tbl <- potter_cast_tbl %>% separate(Actor,c("Actor_FName","Actor_MName","Actor_LName"))}
potter_cast_tbl$Actor_FName[!is.na(potter_cast_tbl$Actor_LName)]<- paste(potter_cast_tbl$Actor_FName[!is.na(potter_cast_tbl$Actor_LName)],potter_cast_tbl$Actor_MName[!is.na(potter_cast_tbl$Actor_LName)],sep=" ")
potter_cast_tbl$Actor_LName[is.na(potter_cast_tbl$Actor_LName)] <- potter_cast_tbl$Actor_MName[is.na(potter_cast_tbl$Actor_LName)]
potter_cast_tbl<-potter_cast_tbl[,-2]
output_dt <- head(potter_cast_tbl,10)
{output_dt %>% kable() %>% kable_styling()}
```
无错误消息。只是尝试获取markdown html针织输出。