Suppose you have the following data: 189 1843 180 537 519 455 406 365 942 776 37
ID: 2947756 • Letter: S
Question
Suppose you have the following data: 189 1843 180 537 519 455 406 365 942 776 372 163 101 249 250
Use the above data to create a 5 by 3 matrix in R with column names: AA, BB, CC; and row names: A, B, C, D, E.
Find row and column totals of the matrix in (a). Now add these row total and column total with the matrix (a), which will show as below: AA BB CC r.sum A 189 455 372 1016 B 1843 406 163 2412 C 180 365 101 646 D 537 942 249 1728 E 519 776 250 1545 c.sum 3268 2944 1135 7347
Now find the values larger than 500 in the matrix in (a) and replace them by the mean of values less than or equal to
Explanation / Answer
x1=c(189,1843,180,537,519,455,406,365,942,776,372,163,101,249,250) > a=matrix(x1,nrow=5,ncol=3) > dimnames(a)=list(c("A","B","C","D","E"),c("AA","BB","CC")) > a AA BB CC A 189 455 372 B 1843 406 163 C 180 365 101 D 537 942 249 E 519 776 250 > c.sum=colSums(a) > a1=rbind(a,c.sum) > r.sum=rowSums(a1) > a2=cbind(a1,r.sum) > a2 AA BB CC r.sum A 189 455 372 1016 B 1843 406 163 2412 C 180 365 101 646 D 537 942 249 1728 E 519 776 250 1545 c.sum 3268 2944 1135 7347 > x=mean(c(189,455,372,406,163,180,365,101,249,250)) > replace(a2,a2Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.