ComeçarComece de graça

Referencing code results in the report

In this exercise, you'll use summarize() and brazil_investment_projects_2018 to find the total investment amount for all projects in Brazil in the 2018 fiscal year. Then, you'll add text to the report to include the information and reference the code results in the text, so that the calculated amount is printed in the text of the report when you knit the file.

Este exercício faz parte do curso

Reporting with R Markdown

Ver curso

Instruções do exercício

  • In the brazil-investment-projects-2018 code chunk, create brazil_investment_projects_2018_total by summarizing the data that was filtered for projects in Brazil in the 2018 fiscal year to create a new column, sum_total_investment, that contains the sum of the total_investment amounts for each of the projects.
  • Add Brazil and 2018 to the sentence on line 47 to describe the information that was calculated.
  • Add a reference to brazil_investment_projects_2018_total in the sentence on line 47, so that the total investment amount for all projects in Brazil in the 2018 fiscal year is included in the knit report.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

{"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### Investment Projects in Brazil in 2018\n\n```{r brazil-investment-projects-2018}\nbrazil_investment_projects_2018 <- investment_services_projects %>%\n  filter(country == \"Brazil\",\n         date_disclosed >= \"2017-07-01\",\n         date_disclosed <= \"2018-06-30\") \n\nbrazil_investment_projects_2018\n\nbrazil_investment_projects_2018_total <- brazil_investment_projects_2018 %>%\n  ___(sum_total_investment = ___(___, na.rm = ___)) \n```\n\nThe total investment amount for all projects in ___ in the ___ fiscal year was ___ million dollars.\n\n\n"}
Editar e executar o código