Affan WS1 Screenshots

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Name: Affan Khaja Syed Date: 10/5/2023

step-by-step explanation of how you created a histogram in R:

1. Define your data: First, you define your data as a vector of rainfall values

using the “c()” function.

Rainfall_data<-c(1,3,4,3,7,2,3,2,9,5,10,5,6,5,7,8,5)

2. Use the hist() function: To create a histogram of your data, you used the hist()

function. This function takes several arguments that allow you to customize

the appearance of your histogram.

hist(Rainfall_Data,main="Histogram of Rainfall",xlab="Rainfall range",

ylab="Frequency",xlim=c(1,10),ylim=c(1,7),col="pink",border="blue",bre

aks=10)
3. View your histogram: After running the hist() function, R will create a

histogram of your data using the arguments you specified. You should see a

window with your histogram displayed.


Step-by-step explanation of how I created my boxplot in R:

1. Define your data: First, you created a matrix” rainfall_data” that contains

your data. Each column represents a month and each row represents a

different year. You also created a vector” month_name” that contains the

names of each month.


month_name <- c("Jun", "Jul", "Aug", "Sep", "Oct")

rainfall_data <- matrix(c(30, 35, 25, 20, 14, 40, 45, 20, 15, 13, 25, 25, 23,

19, 11), nrow=3, ncol=5, byrow=TRUE)

2. Use the boxplot() function: To create a boxplot of your data, you used the

boxplot() function. This function takes several arguments that allow you to

customize the appearance of your boxplot.

boxplot(rainfall_data, main="Monthly Rainfall Variations",

names=month_name, xlab="Month", ylab="Rainfall", col="green")

3. View your boxplot: After running the boxplot() function, R will create a
boxplot of your data using the arguments you specified. You should see a
window with your boxplot displayed.

You might also like