R Markdown

Problem 1:

h<-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, 8571, 13534, 4395, 5729, 14417, 4863, 1951, 13809)

## The height of the highest point in the US (in feet) is:
print(max(h))  
## [1] 20310
## The height of the lowest point in the US (in feet) is:
print(min(h))
## [1] 345
j = sort(h, decreasing = TRUE)
## "Massachusetts' rank among US states for the highest point in the country is:
which(j==3489)
## [1] 31

Problem 2:

x<-seq(from=5, to=-11, by=-0.3)
## Sequence of values from 5 to -11 that progress in steps of 0.3:
print(x)
##  [1]   5.0   4.7   4.4   4.1   3.8   3.5   3.2   2.9   2.6   2.3   2.0   1.7
## [13]   1.4   1.1   0.8   0.5   0.2  -0.1  -0.4  -0.7  -1.0  -1.3  -1.6  -1.9
## [25]  -2.2  -2.5  -2.8  -3.1  -3.4  -3.7  -4.0  -4.3  -4.6  -4.9  -5.2  -5.5
## [37]  -5.8  -6.1  -6.4  -6.7  -7.0  -7.3  -7.6  -7.9  -8.2  -8.5  -8.8  -9.1
## [49]  -9.4  -9.7 -10.0 -10.3 -10.6 -10.9
y = sort(x, decreasing = FALSE)
x<-y
## Sequence in reverse order:
print(x)
##  [1] -10.9 -10.6 -10.3 -10.0  -9.7  -9.4  -9.1  -8.8  -8.5  -8.2  -7.9  -7.6
## [13]  -7.3  -7.0  -6.7  -6.4  -6.1  -5.8  -5.5  -5.2  -4.9  -4.6  -4.3  -4.0
## [25]  -3.7  -3.4  -3.1  -2.8  -2.5  -2.2  -1.9  -1.6  -1.3  -1.0  -0.7  -0.4
## [37]  -0.1   0.2   0.5   0.8   1.1   1.4   1.7   2.0   2.3   2.6   2.9   3.2
## [49]   3.5   3.8   4.1   4.4   4.7   5.0
index<-c(x[1], x[length(x)/2], x[length(x)])
## Index vector:
print(index)
## [1] -10.9  -3.1   5.0

Problem 3:

z<-c(c(6:12), rep(c(5.3), times=3), -3, rep(c(1.2, 3.4, 5.6), each=2))
## Vector:
print(z)
##  [1]  6.0  7.0  8.0  9.0 10.0 11.0 12.0  5.3  5.3  5.3 -3.0  1.2  1.2  3.4  3.4
## [16]  5.6  5.6
## Confirm if length of the vector is 17:
length(z)==17
## [1] TRUE

Problem 4:

musicalbums<-data.frame(Name=c("Thursday's Child", "Orange Blood", "Border:Carnival", "Fight or Escape", "Get Up", "Eyes Wide Open", "Easy", "Unforgiven", "Blue Hour", "Dark Blood"), Songs=c(5, 7, 6, 8, 6, 13, 5, 13, 5, 6), Length=c(15, 20, 15, 26, 12, 43, 13, 37, 16, 18), Ranking=c(4, 4, 18, 5, 1, 72, 8, 6, 25, 4))

## Music Albums Data Frame:
musicalbums
##                Name Songs Length Ranking
## 1  Thursday's Child     5     15       4
## 2      Orange Blood     7     20       4
## 3   Border:Carnival     6     15      18
## 4   Fight or Escape     8     26       5
## 5            Get Up     6     12       1
## 6    Eyes Wide Open    13     43      72
## 7              Easy     5     13       8
## 8        Unforgiven    13     37       6
## 9         Blue Hour     5     16      25
## 10       Dark Blood     6     18       4