开始使用免费开始使用

筛选特定年份

既然您已经按特定国家筛选了项目数据,接下来可以进一步筛选,查看发生在 2018 财年的所有项目。回忆一下,财年从上一年的 7 月 1 日开始,到所述年份的 6 月 30 日结束。

本练习是课程的一部分

使用 R Markdown 生成报告

查看课程

练习说明

  • 在第 4 个代码块中,通过筛选 investment_services_projects 数据中位于 Brazil、且 date_disclosed 落在 2018 财年(起始于 2017 年 7 月 1 日,结束于 2018 年 6 月 30 日)内的项目,创建 brazil_investment_projects_2018
  • 将该代码块的标签设为 brazil-investment-projects-2018
  • 在第 33 行添加一个包含三个井号的标题,为该部分标注为 Investment Projects in Brazil in 2018

交互式实操练习

通过完成这段示例代码来试试这个练习。

{"investment_report.Rmd":"---\ntitle: \"Investment Report\"\ndate: \"`r format(Sys.time(), '%d %B %Y')`\"\noutput: html_document\n---\n\n```{r data, include = FALSE}\nlibrary(readr)\nlibrary(dplyr)\n\ninvestment_annual_summary <- read_csv(\"https://assets.datacamp.com/production/repositories/5756/datasets/d0251f26117bbcf0ea96ac276555b9003f4f7372/investment_annual_summary.csv\")\ninvestment_services_projects <- read_csv(\"https://assets.datacamp.com/production/repositories/5756/datasets/bcb2e39ecbe521f4b414a21e35f7b8b5c50aec64/investment_services_projects.csv\")\n```\n\n\n## Datasets \n\n### Investment Annual Summary\n\nThe `investment_annual_summary` dataset provides a summary of the dollars in millions provided to each region for each fiscal year, from 2012 to 2018.\n```{r investment-annual-summary}\ninvestment_annual_summary\n```\n\n### Investment Projects in Brazil\n\nThe `investment_services_projects` dataset provides information about each investment project from 2012 to 2018. Information listed includes the project name, company name, sector, project status, and investment amounts.\n```{r brazil-investment-projects}\nbrazil_investment_projects <- investment_services_projects %>%\n  filter(country == \"Brazil\") \n```\n\n\n\n```{r}\nbrazil_investment_projects_2018 <- investment_services_projects %>%\n  filter(country == \"Brazil\",\n         ___ >= ___,\n         ___ <= ___) \n\nbrazil_investment_projects_2018\n```\n\n\n"}
编辑并运行代码