assignment2
assignment2
Muskan
2024-11-02
R Markdown
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:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
Including Plots
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.
#1 1:20
c(“Apple”,“Banana”,“Mango”,“Grapes”,“Papaya”)
c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE)
#2 A<-1:10 A[c(3,7)]
B<- 1:10 B[5]<- 100
C<-5:15 C[C>10]
#3 a<-c(3,4,5,6) b<-c(2,7,8,9) a+b
5*a
sum(a) mean(a) sd(a)
#4 X<-c(5,10,15,20,25) X[X>10]
X %% 2==0
Y<-c(TRUE,FALSE,TRUE,FALSE) Z<-c(FALSE,TRUE,FALSE,TRUE) Y & Z Y | Z
#5 X<-1:10 rev(X)
sort(x=c(2.5,-1,-10,3.44),decreasing=FALSE) sort(x=c(2.5,-1,-
10,3.44),decreasing=TRUE)
V<-1:100 V[seq(1,length(V),by=5)]
#6 Z<-c(2,5,NA,7,8,NA) mean(Z,na.rm=TRUE)
Z[is.na(Z)]<-0
is.na(Z)
#7 X<-1:5 Y<-6:10 c(X,Y)
Z<-1:10 list(Z[1:5],Z[6:10])
#8 V<-1:10 Y<-mean(V) V[V>Y]
U<-1:20 which(U<10)