# Mindanao State University
# General Santos City
# Getting the Volume of Data from Data Set in R
# Submitted by: Angga, Princess Joy & Dongosa, Davy, 1-BS MATH
# Math 108 

# the main task is to solve for the total volume of crops produced by region according to the two key columns 

# load necessary packages
library(dplyr)   # for data manipulation
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(readr)   # for reading csv files
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# Load data
data<-read.csv("CornPalay.csv")

# Define functions for calculating volume
calculate_area<-function(Length, Width) {
  Length*Width
}

calculate_yield<-function(area) {
  area * 3 # assuming yield of 3 tons per hectare
}

calculate_volume<-function(area, yield) {
  area * yield
}