Header 1

Header 2

Header 3

Header 4

Header 5

R Markdown cheat sheet

RStudio has created a large number of cheat sheets, including the one-page R Markdown cheat sheet, which are freely available at https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdflink

Question 1

##A. Use ?rivers to learn about the data.

?rivers
## starting httpd help server ... done

B. Find the mean and sd of the rivers data.

mean(rivers)
## [1] 591.1844
sd(rivers)
## [1] 493.8708

C. Make a histogram of the rivers data.

hist(rivers)

D. Get the five number summary of rivers data.

summary(rivers)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   135.0   310.0   425.0   591.2   680.0  3710.0

E. Find the longest and shortest river in the set.

The min and max functions show the minimum and maximum values of a given dataset.

min(rivers)
## [1] 135
max(rivers)
## [1] 3710

F. Make a list of all the lengths of the rivers longer than 1000 miles.

rivers[rivers > 1000]
##  [1] 1459 1450 1243 2348 1171 3710 2315 2533 1306 1054 1270 1885 1100 1205 1038
## [16] 1770

Question 2

  1. According to the data frame airquality , There are a total of 6 variables in the data frame. These variables are used to perform the analysis of the daily air quality.

  2. The Names of the variables are as follows :-

  1. Ozone :- It is used for mean Ozone concentration .
  2. Solar R. :- It is used for Solar Radiation.
  3. Wind :- It is used for average wind speed.
  4. Temp :- It is used for maximum daily temperature.
  5. Month :- It is used for the Month of observation.
  6. Day :- It is used for the Day of month.
  1. The Type of data of each Variable is as follows :-
  1. Ozone :- The data type of Ozone variable is Numeric (int). It’s Unit is parts per billion.
  2. Solar R. :- The data type of Solar Radiation is Numeric (int).
  3. Wind :- The data type of Wind is Numeric (double). It’s Unit is miles per hour.
  4. Temp. :- The data type of Temperature is Numeric (int). It’s Unit is Fahrenheit.
  5. Month :- The data type of Month is Numeric (int).
  6. Day :- The data type of Day is Numeric (int).
  1. I think the data set and varables are reasonable

question 3

y<-.14
r<-.13
o<-.20
Br<-.12
g<-.20
B<-.21
PartA<-1-g
PartB<-r+o+y
Partc<-1-(1-B)^4
Partd<-r*o*Br*g*B*y

Question 4

event <- replicate(10000, {
  coinToss <- sample(c("H", "T"), 7, replace = TRUE) # Simulate outcome of 7 coin tosses
  coinToss
  sum(coinToss == "H") # need 3 heads
  sum(coinToss == "H") == 3
  coinToss[1:7] 
  sum(coinToss[1:7] == "H") == 3 
  sum(coinToss == "H") == 3  
})
mean(event)
## [1] 0.2743