Name: Ethan Curley

Section: DX05

Introduction to RMarkdown

Here are some useful links about RMarkdown.

  1. https://rmarkdown.rstudio.com/articles_intro.html
  2. https://rmarkdown.rstudio.com/lesson-1.html

Below is a RMarkdown template for MA2611 Lab1 Assignment

The first chunk of code will make sure that the knitr package is installed and install it in case it is not. Do not modify this chunk!

To run this chunk, click a green triangle at the right top corner of the chunk.

if (!require("knitr")) {
  install.packages("knitr") # do this once per lifetime
  require("knitr") # do this once per session
}
## Loading required package: knitr

First Part: About Heights Question

  1. Define a vector called heights with them. (Copy and paste your code to following chunk)
heights<-c(2413,20310,12637,2753,14505,14440,2379,447,345,4784,13803,12668,1235, 1257,1671,4041,4145,535,5270,3360,
3489,1979,2302,807,1772,12807,5427,13147,6288,1803,13167,5343,6684,3508,1549,4975,11249,3213,811,3560,
7244,6643,8751,13534,4395,5729,14417,4863,1951,13809)
  1. Redefine the vector heights with the data in decreasing order (Hint: much like the function plot creates plots, the function sort can sort the data in increasing order. Run ?sort to see details)
heights = sort(heights, decreasing = TRUE)
  1. How high is the highest point in the entire USA?

Your answer is 20310.

  1. Mount Greylock is a 3489-foot mountain located in the northwest corner of Massachusetts, the highest point in the state. Where does Massachusetts rank in terms of height of the highest point in the state among US states?

Your answer is 31.

which(heights==3489) 
## [1] 31
  1. Use the function hist to create a histogram of heights. Use the function rug to add the datapoints to the histogram.
hist(heights)
rug(heights)

Second Part: About Cosine

  1. Create a vector x that goes from -7 to 7 with increments of 0.1 (Hint: use the function seq that we used in the first part of this lab)
x<-seq(from=-7,to=7,by=0.1)
  1. Define a vector y that contains, in each coordinate, the cosine of the corresponding coordinate of x
y<-cos(x)
  1. Create a plot with the vector x on the x-axis and the vector y on the y-axis. Write values and cosine as their respective labels, and use red dots to create the plot.
plot(x,y,main='x vs cos(x)', xlab = 'x', ylab = 'cos(x)', col = 'red')