Check the requirements before submission:

  1. Modify the title above, e.g. Lab exercise for XXX.
  2. Write down your name and student ID No. in the author line above.
  3. Modify the date.
  4. Please submit .rmd file, the generated .html file and .pdf , data file (if applicable) into iSpace.

Setup
* If you have not installed Rmarkdown in your Rstudio, please install the following packages. Please delete the ‘Setup’ section after installation.

# install packages
#install.packages("rmarkdown")
install.packages("tinytex")
install.packages("knitr")


Tips:
* If there are still some errors until the ddl and you can not generate your .html file, please try to not evaluate the R code chunk, which produce the error. Add the option eval=FALSE. Please delete the ‘Tips’ section when you submit.

# adding the option like this
# ```{r eval=FALSE}
# 
# ```
# this chunk will be not evaluated

Q1.
# write down you code here
x=c(11,10,5,9,14,12,18,2,17,9,1,7,1,15,16,7,16,12,13,3,8,3,11,1,5,7,7,10,6,10,17,13,1,2,17,1,15,8,12,3,6,15,10,3,10,12,19,17,15,12,18,17,1,13,5,9,18,2,20,16,15,7,9,12,12,5,5,7,7,9,17,7,15,11,10,12,19,8,13,3,7,14,13,18,1,11,18,1,12,18,5,12,5,10,3,6,11,12,1,3)  
x[seq(2,length(x),by=2)]<-x[seq(2,length(x),by=2)]+3
x
##   [1] 11 13  5 12 14 15 18  5 17 12  1 10  1 18 16 10 16 15 13  6  8  6 11  4  5
##  [26] 10  7 13  6 13 17 16  1  5 17  4 15 11 12  6  6 18 10  6 10 15 19 20 15 15
##  [51] 18 20  1 16  5 12 18  5 20 19 15 10  9 15 12  8  5 10  7 12 17 10 15 14 10
##  [76] 15 19 11 13  6  7 17 13 21  1 14 18  4 12 21  5 15  5 13  3  9 11 15  1  6
# write down you code here
sqrt(x)
##   [1] 3.316625 3.605551 2.236068 3.464102 3.741657 3.872983 4.242641 2.236068
##   [9] 4.123106 3.464102 1.000000 3.162278 1.000000 4.242641 4.000000 3.162278
##  [17] 4.000000 3.872983 3.605551 2.449490 2.828427 2.449490 3.316625 2.000000
##  [25] 2.236068 3.162278 2.645751 3.605551 2.449490 3.605551 4.123106 4.000000
##  [33] 1.000000 2.236068 4.123106 2.000000 3.872983 3.316625 3.464102 2.449490
##  [41] 2.449490 4.242641 3.162278 2.449490 3.162278 3.872983 4.358899 4.472136
##  [49] 3.872983 3.872983 4.242641 4.472136 1.000000 4.000000 2.236068 3.464102
##  [57] 4.242641 2.236068 4.472136 4.358899 3.872983 3.162278 3.000000 3.872983
##  [65] 3.464102 2.828427 2.236068 3.162278 2.645751 3.464102 4.123106 3.162278
##  [73] 3.872983 3.741657 3.162278 3.872983 4.358899 3.316625 3.605551 2.449490
##  [81] 2.645751 4.123106 3.605551 4.582576 1.000000 3.741657 4.242641 2.000000
##  [89] 3.464102 4.582576 2.236068 3.872983 2.236068 3.605551 1.732051 3.000000
##  [97] 3.316625 3.872983 1.000000 2.449490
Q2.
# write down you code here
x<-c(3,15,9,12,-1,-12,9,6,1)
x[c(x>0)]=0
# write down you code here
x<-c(3,15,9,12,-1,-12,9,6,1)
x[c(x%%3==0)]=3
# write down you code here
x<-c(3,15,9,12,-1,-12,9,6,1)
x[c(x%%2==0)]<-x[c(x%%2==0)]*5
# write down you code here
x<-c(3,15,9,12,-1,-12,9,6,1)
y<-x[c(x>10)]
# write down you code here
x<-c(3,15,9,12,-1,-12,9,6,1)
(1:9)[c(x>4)]
## [1] 2 3 4 7 8

Answer: write here

Q3.
# write down you code here
x=1
n=(0:19)
e_approx<-sum(x^n/factorial(n))
Q4.
# write down you code here
t<-c(17,16,20,24,22,15,21,15,17,22)
max_t<-max(t)
mean_t<-mean(t)
min_t<-min(t)

Description/analysis: write here

# write down you code here
t<-c(17,16,20,24,22,15,21,15,17,22)
t[c(4)]<-18
max_t<-max(t)
mean_t<-mean(t)
min_t<-min(t)

Description/analysis: write here

# write down you code here
t<-c(17,16,20,24,22,15,21,15,17,22)
sum(c(t>20))
## [1] 4

Description/analysis: write here

# write down you code here
t<-c(17,16,20,24,22,15,21,15,17,22)
sum(c(t<17))/10
## [1] 0.3

Description/analysis: write here