Posts

Showing posts from February, 2023

Assignment 6

 # Part 1  > A <- matrix(c(2,0,1,3), ncol=2) > B <- matrix(c(5,2,4,-1), ncol=2) > A + B      [,1] [,2] [1,]    7    5 [2,]    2    2 > A - B      [,1] [,2] [1,]   -3   -3 [2,]   -2    4 # Part 2 > diag(c(4,1,2,3))      [,1] [,2] [,3] [,4] [1,]    4    0    0    0 [2,]    0    1    0    0 [3,]    0    0    2    0 [4,]    0    0    0    3 # Part 3 > matrix(c(3,2,2,2,2,1,3,0,0,0,1,0,3,0,0,1,0,0,3,0,1,0,0,0,3), nrow = 5, byrow = FALSE)      [,1] [,2] [,3] [,4] [,5] [1,]    3    1    1    1    1 [2,]    2    3    0    0    0 [3,]    2    0  ...

Assignment 5

 A <- matrix(1:100, nrow=10)   B <- matrix(1:1000, nrow=10) # Transpose A and B   t(A) t(B) # Create vectors a <- c(1:100) b <- c(1:1000) X <- A*a Y <- B*b a=c(1:100) b=c(1:1000) A*a %*% B*b %*%    S=matrix(A, nrow=2) det(S) det(A) det(B) det(X) det(Y)

Assignment 4

Image
 # frequency of hospital visits by patients during 12 month period Freq <- c(0.6,0.3,0.4,0.4,0.2,0.6,.3,0.4,0.9,0.2) # blood pressure of each individual patient  BP <- c(103,87,32,43,59,109,78,205,135,178) # first doctor evaluation of BP, where 1=bad and 0=good First <- c(1,1,1,1,0,0,0,0,NA,1) # second and final evaluation of BP, where 0=low and 1=high Second <- c(0,0,1,1,0,0,1,1,1,1) Final <- c(0,1,0,1,0,1,0,1,1,1) # contain everything under hospital data.frame.  hospital.df <- data.frame(Freq,BP,First,Second,Final)  # Lets make boxplot of data boxplot(hospital.df, main= "Patient Data") # Lets make histograms of dats hist(hospital.df$Freq, main= "Histogram Hospital Visits", xlab= "hospital visits") hist(hospital.df$BP, main= "Histogram Blood Pressure", xlab= "Blood Pressure") hist(hospital.df$First, main= "Histogram First doctor evaluation of BP", xlab= "Evaluation of BP") hist(hospital.df$Second, ...