Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Exercises for RStudio, Exercises of Statistics

Here is my exercise solutions for the textbook of RStudio.

Typology: Exercises

2022/2023

Uploaded on 10/04/2023

yerin-lee
yerin-lee 🇺🇸

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
> Homework 1 Yerin Lee
> #1.9
> # 1. What is the smallest amount? The largest?
> Cooper<-c(15.9, 21.4, 19.9, 21.9, 20.0, 16.5, 17.9, 17.5)
> min(Cooper)
[1] 15.9
> max(Cooper)
[1] 21.9
> # 2. Find the average amount.
> mean(Cooper)
[1] 18.875
> # 3. Find the differences of the largest and smallest amounts from the mean.
> diff(Cooper)
[1] 5.5 -1.5 2.0 -1.9 -3.5 1.4 -0.4
> min(diff(Cooper))
[1] -3.5
> max(diff(Cooper))
[1] 5.5
First, I put the data for the cooper. Next, I got the minimum(the smallest amount) of the
cooper which is 15.9, maximum(the largest amount) of the cooper which is 21.9, and the
mean(average amount) of the cooper which is 18.875. To find the differences of the largest
and smallest amounts from the mean, I have to find out the differences first. The differences
of total data of Cooper is 5.5, -1.5, 2.0, -1.9, -3.5, 1.4, -0.4. Therefore, the minimum(the
smallest amount) of the cooper is -3.5, the maximum(the largest amount) of the cooper is
5.5.
> # 1.15
> # According to The Digital Bits (http://www.digitalbits.com/),
> # monthly sales (in 10,000s) of DVD players in 2003 were
> JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
79 74 161 127 133 210 99 143 249 249 368 302
> # Enter the data into a data vector dvd.
> # By slicing, form two data vectors: one containing the months with 31 days, the other the
remaining months.
> # Compare the means of these two data vectors.
> dvd<-c(79,74,161,127,133,210,9,143,249,249,368,302)
> dvd31<-c(1,3,5,7,8,10,12)
> dvd30<-c(2,4,6,9,11)
> mean(dvd31)
[1] 6.571429
> mean(dvd30)
[1] 6.4
> mean(dvd31)-mean(dvd30)
[1] 0.1714286
pf3

Partial preview of the text

Download Exercises for RStudio and more Exercises Statistics in PDF only on Docsity!

Homework 1 Yerin Lee #1.

1. What is the smallest amount? The largest?

Cooper<-c(15.9, 21.4, 19.9, 21.9, 20.0, 16.5, 17.9, 17.5) min(Cooper) [1] 15. max(Cooper) [1] 21.

2. Find the average amount.

mean(Cooper) [1] 18.

3. Find the differences of the largest and smallest amounts from the mean.

diff(Cooper) [1] 5.5 -1.5 2.0 -1.9 -3.5 1.4 -0. min(diff(Cooper)) [1] -3. max(diff(Cooper)) [1] 5. First, I put the data for the cooper. Next, I got the minimum(the smallest amount) of the cooper which is 15.9, maximum(the largest amount) of the cooper which is 21.9, and the mean(average amount) of the cooper which is 18.875. To find the differences of the largest and smallest amounts from the mean, I have to find out the differences first. The differences of total data of Cooper is 5.5, -1.5, 2.0, -1.9, -3.5, 1.4, -0.4. Therefore, the minimum(the smallest amount) of the cooper is -3.5, the maximum(the largest amount) of the cooper is 5.5.

1.

According to The Digital Bits (http://www.digitalbits.com/),

monthly sales (in 10,000s) of DVD players in 2003 were

JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC 79 74 161 127 133 210 99 143 249 249 368 302

Enter the data into a data vector dvd.

By slicing, form two data vectors: one containing the months with 31 days, the other the

remaining months.

Compare the means of these two data vectors.

dvd<-c(79,74,161,127,133,210,9,143,249,249,368,302) dvd31<-c(1,3,5,7,8,10,12) dvd30<-c(2,4,6,9,11) mean(dvd31) [1] 6. mean(dvd30) [1] 6. mean(dvd31)-mean(dvd30) [1] 0.

I put twelve datas for monthly sales of DVD players as “dvd”. I sliced them by a month that has 30 days and a month that has 31 days. I named them “dvd31” and “dvd30”. After that, I got the mean of dvd31 which is 6.571429, and the mean of dvd30 which is 6.4. Finally, to compare these two means, I subtracted the mean of dvd31 by mean of dvd30.

1.

The times variable in the data set nym. 2002 (UsingR) contains the time to finish for

several participants in the 2002 New York City Marathon. Answer these questions.

1. How many times are stored in the data set?

data("nym.2002") length(nym.2002$time) [1] 1000

2. What was the fastest time in minutes? Convert this into hours and minutes using R.

fastest<-min(nym.2002$time) fastest [1] 147. paste(fastest%/%60, round(fastest%%60), sep=":") [1] "2:27"

3. What was the slowest time in minutes? Convert this into hours and minutes using R.

slowest<-max(nym.2002$time) slowest [1] 566. paste(slowest%/%60, round(slowest%%60), sep=":") [1] "9:27" To follow up the variable in the data set nym.2002, I ran for data(“nym.2002”). To find the time to finish participants, I ran for length(nym.2002$time) and got 1000 for that. Using the minimum, I got the fastest time in minutes which is 147.333… I converted that to hours by dividing them by 60 and got 6 hours and 27 minutes by rounding. Next, using the maximum, I got the slowest time in minutes which is 566.7833… I converted that to hours by dividing them by 50 and got 9 hours and 27 minutes by rounding.

1.