We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The file read in contains information, such as flights from/to/via, etc so that it can automatically calculate emissions for a whole data set at once.
Issue #14 covers automating a data set into the correct format.
calculate_emissions <- function(data, emission_column = "emission_type", airplane_from = "flight_from", airplane_to = "flight_to", airplane_via = "flight_via", airplane_n = "flight_n", airplane_radiative_force = TRUE, airplane_WTT = TRUE, airplane_return = "flight_return", airplane_class, hotel_location = "accomodation_at", hotel_nights = "accomodation_nights", hotel_rooms = "accomodation_n"){ emissions <- NULL for (i in 1:nrow(data)){ emission_type <- data %>% dplyr::select( emission_column ) if (emission_type[i,] == "flight"){ if (missing(airplane_class)) airplane_class = "economy" emissions[i] <- airplane_emissions(from = data[[airplane_from]][[i]], to = data[[airplane_to]][[i]], via = data[[airplane_via]][[i]], num_people = data[[airplane_n]][[i]], radiative_force = airplane_radiative_force, include_WTT = airplane_WTT, round_trip = data[[airplane_return]][[i]], class = data[[airplane_class]][[i]]) } else if (emission_type[i,] == "train"){ # from, to, via = NULL, num_people = 1, times_journey = 1, include_WTT = TRUE, round_trip = FALSE } else if (emission_type[i,] == "accomodation"){ emissions[i] <- hotel_emissions(location = data[[hotel_location]][[i]], nights = data[[hotel_nights]][[i]], rooms = data[[hotel_rooms]][[i]]) } } data <- data %>% mutate(emissions = emissions) #print() return(sum(emissions, na.rm = TRUE)) } calculate_emissions(expense_report)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The file read in contains information, such as flights from/to/via, etc so that it can automatically calculate emissions for a whole data set at once.
Issue #14 covers automating a data set into the correct format.
The text was updated successfully, but these errors were encountered: