This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
#Problem 1
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, 8571, 13534, 4395, 5729, 14417, 4863, 1951, 13809)
sort(Heights,decreasing=FALSE)
## [1] 345 447 535 807 811 1235 1257 1549 1671 1772 1803 1951
## [13] 1979 2302 2379 2413 2753 3213 3360 3489 3508 3560 4041 4145
## [25] 4395 4784 4863 4975 5270 5343 5427 5729 6288 6643 6684 7244
## [37] 8571 11249 12637 12668 12807 13147 13167 13534 13803 13809 14417 14440
## [49] 14505 20310
max(Heights)
## [1] 20310
min(Heights)
## [1] 345
Heightswmass <- 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, 3489)
sort(Heightswmass, decreasing=FALSE)
## [1] 345 447 535 807 811 1235 1257 1549 1671 1772 1803 1951
## [13] 1979 2302 2379 2413 2753 3213 3360 3489 3489 3508 3560 4041
## [25] 4145 4395 4784 4863 4975 5270 5343 5427 5729 6288 6643 6684
## [37] 7244 8571 11249 12637 12668 12807 13147 13167 13534 13803 13809 14417
## [49] 14440 14505 20310
#Mass is ranked number 32 out of all of the highest points
# question 2
vec1 <- seq(5, -11, by = -0.3)
print(vec1)
## [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
vec1<-seq(-11,5,by =0.3)
print (vec1)
## [1] -11.0 -10.7 -10.4 -10.1 -9.8 -9.5 -9.2 -8.9 -8.6 -8.3 -8.0 -7.7
## [13] -7.4 -7.1 -6.8 -6.5 -6.2 -5.9 -5.6 -5.3 -5.0 -4.7 -4.4 -4.1
## [25] -3.8 -3.5 -3.2 -2.9 -2.6 -2.3 -2.0 -1.7 -1.4 -1.1 -0.8 -0.5
## [37] -0.2 0.1 0.4 0.7 1.0 1.3 1.6 1.9 2.2 2.5 2.8 3.1
## [49] 3.4 3.7 4.0 4.3 4.6 4.9
length(vec1)
## [1] 54
vec1[1]
## [1] -11
median(vec1)
## [1] -3.05
vec1[54]
## [1] 4.9
#problem 3
b<-c(rep(c(1.2,3.4,5.6),times=1,each=2),seq(from=6,to=12),rep(c(5.3), times=1, each=3), rep (c(-3),times=1, each=1))
print(b)
## [1] 1.2 1.2 3.4 3.4 5.6 5.6 6.0 7.0 8.0 9.0 10.0 11.0 12.0 5.3 5.3
## [16] 5.3 -3.0
length(b)
## [1] 17
#problem 4
#create a data frame that contains 10 rows and 3 columns
mylife <- data.frame(classes=c("Stats","ECE","English", "CS", "Calc1", "Calc2", "Calc2", "Writing", "Sociology", "Lab"),
Grades=c("A","B","c","A","B","C", "A","B","C","A"),easy=factor(c("Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes", "Yes","Yes")))
mylife
## classes Grades easy
## 1 Stats A Yes
## 2 ECE B Yes
## 3 English c Yes
## 4 CS A Yes
## 5 Calc1 B Yes
## 6 Calc2 C Yes
## 7 Calc2 A Yes
## 8 Writing B Yes
## 9 Sociology C Yes
## 10 Lab A Yes
summary(mylife)
## classes Grades easy
## Length:10 Length:10 Yes:10
## Class :character Class :character
## Mode :character Mode :character
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.