Experiment 1
Basic plotting in R
CODE
Pie Chart
# Sample data for the pie chart
labels <- c("Category 1", "Category 2", "Category 3", "Category 4", "Category 5")
values <- c(30, 20, 15, 10, 25)
# Create a pie chart
pie(values, labels = labels, col = rainbow(length(labels)), main = "Sample Pie Chart")
Bar Chart
# Sample data for the bar chart
categories <- c("Category 1", "Category 2", "Category 3", "Category 4", "Category 5")
values <- c(40, 10, 35, 10, 15)
# Create a bar chart
barplot(values, names.arg = categories, col = "blue", main = "Sample Bar Chart", xlab = "Categories", ylab = "Values")
Histogram
# Sample data for the histogram
data <- c(23, 45, 34, 26, 33, 13, 12, 55, 67, 39, 54, 17, 35, 23, 56, 78, 90, 34, 67, 78)
# Create a histogram
hist(data, breaks = "FD", col = "lightgreen", main = "Sample Histogram", xlab = "Values", ylab = "Frequency")