[go: up one dir, main page]

0% found this document useful (0 votes)
74 views6 pages

R Assignment 1

Uploaded by

jayadeeps1101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views6 pages

R Assignment 1

Uploaded by

jayadeeps1101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

STAT 260 R Assignment 1

By Jayadeep Sayani

1a)

Commands:

number.of.boys <- c(80, 82, 85, 90, 88, 92, 95, 98, 100, 105, 110, 115, 120, 125) r
number.of.girls <- c(20, 22, 25, 30, 35, 40, 26, 30, 20, 35, 19, 25, 20, 15)

Output:

No output.

1b)

Commands:

boxplot(number.of.boys, number.of.girls, names = c("Number of Boys","Number of Girls"), r


main = "Boxplots of Number of Boys and Number of Girls in the Engineering Department")

Output:
2a)

Commands:

jem.data <- c(1.71, 1.73, 1.81, 1.82, 1.80)


kimber.data <- c(171, 173, 181, 182, 180)
mean(jem.data)
mean(kimber.data)
sd(jem.data)
sd(kimber.data)

Output:

> mean(jem.data)
[1] 1.774

> mean(kimber.data)
[1] 177.4

> sd(jem.data)
[1] 0.05029911

> sd(kimber.data)
[1] 5.029911

2b)

Commands:

jem.cv <- sd(jem.data) / mean(jem.data)


kimber.cv <- sd(kimber.data) / mean(kimber.data)
jem.cv
kimber.cv

Output:

> jem.cv
[1] 0.0283535

> kimber.cv
[1] 0.0283535
3a)

Commands:

set.seed(2025)
simvector = rnorm(600, 100, 24)
summary(simvector)

hist(simvector, main="Histogram of the Random Dataset")

Output:

Command:

boxplot(simvector, main="Boxplot of the Random Dataset")

Output:
3b)

Command:

IQR(simvector)

Output:

> IQR(simvector)
[1] 31.92888

3c)

The histogram appears symmetric, suggesting that the data distribution is approximately normal. There is a
single peak around the mean (100), indicating that it's a unimodal histogram. The data is spread between
approximately 50 and 150, consistent with the mean and standard deviation.

The boxplot has the median centrally located within the box, indicating that the dataset is symmetric around
the mean, consistent with a normal distribution. The lower and upper quartile range is approximately 20,
closely relating to the standard deviation.
4a)

Commands:

study.hours <- c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)


exam.scores <- c(60, 61, 67, 72, 78, 81, 82, 89, 90, 95)
plot(study.hours, exam.scores,
main = "Scatterplot of Study Hours vs Exam Scores", xlab = "Study Hours", ylab = "Exam Sco
res")

Output:

4b)

Commands:

cor(study.hours, exam.scores)

Output:

> cor(study.hours, exam.scores)


[1] 0.9916109

4c)

The correlation coefficient is very close to 1. A correlation coefficient near 1 indicates a very strong positive
linear relationship between the study hours and exam scores. Thus, it is reasonable to model this data with a
linear relationship. The linear relationship is positive, therefore, as study hours increase, exam scores
increase.

You might also like