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.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
ggplot(PlantGrowth, aes(x = group, y = weight, color = group, size = weight)) +
geom_point(alpha = 0.7) +
scale_color_manual(values = c("skyblue", "orange", "purple")) +
labs(
title = "Effect of Fertilizers on Plant Growth",
x = "Fertilizer Type",
y = "Weight",
color = "Fertilizer Type",
size = "Weight"
)
ggplot(PlantGrowth, aes(x = weight, fill = group)) +
geom_histogram(binwidth = 1, position = "identity", alpha = 0.7) +
scale_fill_manual(values = c("black", "brown", "green")) +
labs(
title = "Histogram of Plant Weights by Fertilizer Type",
x = "Weight",
y = "Frequency",
fill = "Fertilizer Type"
)
ggplot(PlantGrowth, aes(x = group, y = weight, fill = group)) +
geom_boxplot(alpha = 0.7) +
scale_fill_manual(values = c("navyblue", "red", "lightgreen")) +
labs(
title = "Boxplot of Plant Weights by Fertilizer Type",
x = "Fertilizer Type",
y = "Weight",
fill = "Fertilizer Type"
)
ggplot(PlantGrowth, aes(x = weight, fill = group)) +
geom_density(alpha = 0.7) +
scale_fill_manual(values = c("blue", "red", "green")) +
labs(
title = "Density Plot of Plant Weights by Fertilizer Type",
x = "Weight",
fill = "Fertilizer Type"
)
ggplot(PlantGrowth, aes(x = group, fill = group)) +
geom_bar() +
scale_fill_manual(values = c("pink", "white", "maroon")) +
labs(
title = "Bar Graph of Plant Weights by Fertilizer Type",
x = "Fertilizer Type",
y = "Count",
fill = "Fertilizer Type"
)
ggplot(PlantGrowth, aes(x = group, y = weight, fill = group)) +
geom_violin(alpha = 0.7) +
scale_fill_manual(values = c("grey", "yellow", "red")) +
labs(
title = "Violin Plot of Plant Weights by Fertilizer Type",
x = "Fertilizer Type",
y = "Weight",
fill = "Fertilizer Type"
)
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.