内联代码只接受一个已经存在的变量。R代码块返回正确的值,但内联代码返回0。
我的代码:
---
title: "Test"
output: html_document
---
```{r include=FALSE, echo=FALSE, message=FALSE, warning=FALSE}
library(tidyverse)
library(lubridate)
first_date <- ymd("2019-01-28")
last_date <- ymd("2020-03-12")
last_date - first_date
my_interval <- interval(first_date, last_date)
number_of_days <- as.period(my_interval, unit = "day")
number_of_days
without lubridate, the time difference is `r last_date - first_date` days and with lubridate it's `r number_of_days` days
我的输出: