knitr::opts_chunk$set(echo = TRUE)
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
library(tidyverse) library(testthat) library(dplyr) library(devtools) library(roxygen2) library(Assignment5) ghg <- read_csv("GHG.csv") # devtools::document() this will update the documentation # after running that code, it should open the help page when the functions are called
ng_emissions = ghg %>% filter(Fuel_Type == "Natural Gas") %>% select(Total_CO2_Emissions) %>% summarize(mean = (sum(Total_CO2_Emissions)/7))
annual_emissions = ghg %>% group_by(Year) %>% summarize(sum_col = sum(Total_CO2_Emissions)) %>% arrange(-Year) %>% head(10)
emissions_year = array(1:40, dim=c(5,4,2), #fill array with numbers 1-40 FAKE DATA dimnames = list(c('Transportation', 'Electricity_Generation', 'Residential', 'Commercial', 'Industrial'), c('Diesel', 'Gasoline', 'Coal', 'Natural Gas'), c(2010,2016))) # add column names emissions_year #each ton is taxed $1,000 - econ cost for emissions for each sector cost = apply(emissions_year, c(1), sum)*1000
less_emissions = ghg%>% dplyr::filter(Fuel_Type != "Coal") %>% dplyr::select(Total_CO2_Emissions) %>% dplyr::summarize((sum(Total_CO2_Emissions)/10*.1))
usethis::use_test() source("R/add_total_emissions_year.R") test_that("Data from 2019 is not included", { data(ghg) ghg_2019 <- ghg %>% dplyr::filter(Year == 2019) expect_false(add_total_emissions_year(ghg_em_year = ghg_2019) > 0) }) source("R/average_ng.R") test_that("Average natural gas emissions are numerical", { data(ghg) expect_is(average_ng(ghg_data = ghg), "numeric") }) source("R/average_ng.R") test_that("Test that the average natural gas emissions in 2016 were 165.85", { data(ghg) ghg_2016 <- ghg %>% dplyr::filter(Year == 2016) expect_true(average_ng(ghg_data = ghg_2016) > 165) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.