———————————Assignment 4
title: “R Notebook” output: html_notebook
Exploring the CO2 Dataset Ken Wood (2024) In this assignment basic statistical analysis techniques is applied using the R programming language on the CO2 dataset.
Load the package
library(gtsummary)
library (dplyr)
##
## 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(dataset)
library(ggplot2)
#Import the CO2 dataset
head(CO2)
## Plant Type Treatment conc uptake
## 1 Qn1 Quebec nonchilled 95 16.0
## 2 Qn1 Quebec nonchilled 175 30.4
## 3 Qn1 Quebec nonchilled 250 34.8
## 4 Qn1 Quebec nonchilled 350 37.2
## 5 Qn1 Quebec nonchilled 500 35.3
## 6 Qn1 Quebec nonchilled 675 39.2
A set of summary stats for the dataset
summary(CO2)
## Plant Type Treatment conc uptake
## Qn1 : 7 Quebec :42 nonchilled:42 Min. : 95 Min. : 7.70
## Qn2 : 7 Mississippi:42 chilled :42 1st Qu.: 175 1st Qu.:17.90
## Qn3 : 7 Median : 350 Median :28.30
## Qc1 : 7 Mean : 435 Mean :27.21
## Qc3 : 7 3rd Qu.: 675 3rd Qu.:37.12
## Qc2 : 7 Max. :1000 Max. :45.50
## (Other):42
hist(CO2$uptake,
main="Histogram of CO2$uptake",
xlab="conc Value",
ylab="Frequency",
col="blue",
border="black")
Interpretation: CO₂ concentration ranged from 95 to 1000 ppm, with a median of 350 ppm and a mean of 435 ppm, indicating a slight right skew. The 25th and 75th percentiles were 175 ppm and 675 ppm, respectively. This shows that plants were exposed to a broad gradient of CO₂ levels, from low to very high concentrations.
Create a Boxplot Comparing two samples
ggplot(CO2, aes(x=Type, y=uptake)) + geom_boxplot()
Interpretation: Quebec plants show a higher median CO₂ uptake (~37) with
more consistent values, although a few low outliers are present. In
contrast, Mississippi plants have a lower median uptake (~20) and
greater variability, but without extreme outliers. Overall, Quebec
plants absorb more CO₂ than Mississippi plants.