Assignment 1 Course: Intro to R Course Instructor: Ms. Farhana Zahir Date: Jan 28, 2024

##1. Calculations Using R ##1.(a)

(5*4)^(4*5)-56
## [1] 1.048576e+26

##1.(b)

23-1*(8-12)
## [1] 27

##1.(c)

56/8*(3+4)
## [1] 49

##1.(d)

45-5*8+(8+9)
## [1] 22

##2. Creation of vectors: a, b, c

a<- c(2,5,6,7)
b<- c(1,0,9,8)
c<- c(6,5,8,3)

##Rowbind vectors to form a 3x4 matrix.

d<- c(a,b,c)
students<- matrix(d, byrow=TRUE,nrow=3)
students
##      [,1] [,2] [,3] [,4]
## [1,]    2    5    6    7
## [2,]    1    0    9    8
## [3,]    6    5    8    3

##Column names with days ##Row names to (Present, Absent, On Leave)

colnames(students)<- c("Mon", "Tues", "Wed", "Thurs")
rownames(students)<- c("Present", "Absent", "On Leave")
students
##          Mon Tues Wed Thurs
## Present    2    5   6     7
## Absent     1    0   9     8
## On Leave   6    5   8     3

##calculations of rowsums and columnsums

row<- rowSums(students)
row
##  Present   Absent On Leave 
##       20       18       22
col<- colSums(students)
col
##   Mon  Tues   Wed Thurs 
##     9    10    23    18

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.