Question

NBA ANALYSIS USING R MATRIX QUESTIONS 22 55 25 16 100 25 66 82 29 18 22 85WRITE CODE FOR NEXT 10 QUESTIONS USING THE IMAGE ABOVE !!

1.Create a matrix (called scores) in the picture above, using MATRIX function.

2. Create a matrix (called scores) in the picture above, using RBIND function.

3. Create a matrix (called scores) in the picture above, using CBIND function.

4. Print out number 66 from the scores matrix.

5. Print out numbers number 16, 82, 85 from the scores matrix.  Hint: scores [ , 2] prints the numbers 55, 25, 18.

6. Print out numbers number 100, 25, 66, 82 from the scores matrix.

7. Create a vector called names with values “Bob”, “Julie”, “Tom” and assign these names to each row of the scores matrix..

8. Create a vector called years with values “2010”, “2011”, “2012”, “2013” and assign the years to each column of the scores matrix.

9. Print out number 100 by using named row and column from last 2 questions.  Hint: scores ['Bob', '2010'] prints 22.

10. Print out the scores for Julie for years 2012 and 2013.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PLEASE LIKE THIS ANSWER, IT HELPS ME A LOT. THANK YOU!!!

1.

scores = matrix(c(22,100,29,55,25,18,25,66,22,16,82,85),nrow=3,ncol=4)
scores #printing matrix to the screen
scores[2,3]  #Question-4

2.

scores = cbind(c(22,100,29),c(55,25,18),c(25,66,22),c(16,82,85))
scores #printing matrix to the screen
scores[2,3] #Question-4

3.

x1 <- c(22,100,29)
x2 <- c(55,25,18)
x3 <- c(25,66,22)
x4 <- c(16,82,85)

data_1 <- data.frame(x1,x2,x3,x4)

scores = rbind(data_1)
scores #printing matrix to the screen

scores[2,3]  #Question-4

output is

  [,1] [,2] [,3] [,4]
[1,]   22   55   25   16
[2,]  100   25   66   82
[3,]   29   18   22   85
[1] 66
     [,1] [,2] [,3] [,4]
[1,]   22   55   25   16
[2,]  100   25   66   82
[3,]   29   18   22   85
[1] 66
   x1 x2 x3 x4
1  22 55 25 16
2 100 25 66 82
3  29 18 22 85
[1] 66

scores<- matrix(c(22,55,25,16,100,25,66,82,29,18,22,85), nrow = 3, byrow = TRUE)
print(scores)
#######part 5
print(scores[,4])

######part 6
print(scores[2,])

#####part 7
names<-c('Bob','Julie','Tom')
rownames(scores)<-names
#print(scores)

######part 8
years<-c('2010','2011','2012','2013')
colnames(scores)<-years

#####part 9
print(scores['Julie','2010'])

#####part10
print(scores['Julie',c('2012','2013')])

5 3 scores<- matrix(c(22,55,25,16,100,25,66,82, 29,18,22,85), nrow = 3, byrow = TRUE) 4 print (scores) #####part 5 6 print (s

3 scores<- matrix(c(22,55,25,16,100,25,66,82,29,18,22,85), nrow = 3, byrow = TRUE) 4 print (scores) 5 #######part 5 6 print (scores[,4]) 8 ######part 6 9 print (scores [2,]) 11 #####part 7 12 names<-c('Bob', 'Julie', 'Tom') 13 rownames (scores)<-names 14 #print(scores) 15 16 ######part 8 17 years<-c('2010', '2011','2012', '2013') 18 colnames (scores)<-years 20 #####part 9 21 print (scores['Julie', '2010']) 22 23 #####part 10 24 print (scores ['Julie',c("2012', '2013'))) Run it (F8) Save it [ + ] Show input Absolute running time: 0.46 sec, cpu time: 0.47 sec, memory peak: 30 Mb, absolute service time: 0,47 sec [,1] [,2] [,3] [,4] [1,] 22 55 25 16 [2,] 100 25 66 82 [3,] 29 18 22 85 [1] 16 82 85 [1] 100 25 66 82 [1] 100 2012 2013 66 82

3 scores<- matrix(c(22,55,25,16,100,25,66,82,29,18,22,85), nrow = 3, byrow = TRUE) 4 print (scores) 5 #######part 5 6 print (scores[,4]) 8 ######part 6 9 print (scores [2,]) 11 #####part 7 12 names<-c('Bob', 'Julie', 'Tom') 13 rownames (scores)<-names 14 #print(scores) 15 16 ######part 8 17 years<-c('2010', '2011','2012', '2013') 18 colnames (scores)<-years 20 #####part 9 21 print (scores['Julie', '2010']) 22 23 #####part 10 24 print (scores ['Julie',c("2012', '2013'))) Run it (F8) Save it [ + ] Show input Absolute running time: 0.46 sec, cpu time: 0.47 sec, memory peak: 30 Mb, absolute service time: 0,47 sec [,1] [,2] [,3] [,4] [1,] 22 55 25 16 [2,] 100 25 66 82 [3,] 29 18 22 85 [1] 16 82 85 [1] 100 25 66 82 [1] 100 2012 2013 66 82

Add a comment
Know the answer?
Add Answer to:
WRITE CODE FOR NEXT 10 QUESTIONS USING THE IMAGE ABOVE !! 1.Create a matrix (called scores)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which...

    About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...

  • See the image below and write the code using C++, without using variables, only recursion. 3....

    See the image below and write the code using C++, without using variables, only recursion. 3. 5 a [DO NOT USE ANY VARIABLES Write a C++ function that takes two integer parameters (a and b) and prints a list of all the integers between a and b-1 (inclusive). one (2, 12) should print 2 34567 8 9 10 11. one (2, 13) should print 2 34567 8 9 10 11 12 b. [D NOT USE ANY VARIABLES Write a C++...

  • Step 1. Start Netbeans and create a project called ArrayLab Step 2. Write the main method...

    Step 1. Start Netbeans and create a project called ArrayLab Step 2. Write the main method  Declare and initialize an array called myNums int myNums = {3, 8, 12, 4, 2, 9, 6};  Declare an int called largestNum and set it to 0.  Write a for loop that prints the array for (int index = 0; index < myNums.length; index++) { System.out.println(myNums[index] + “ “); }  Write a for loop that prints the array backwards ...

  • 5.4 Java Create a program that generates SuperLotto lottery numbers. Create a class called SuperLottoPlus.java Create...

    5.4 Java Create a program that generates SuperLotto lottery numbers. Create a class called SuperLottoPlus.java Create a method called generateSuperLottoNumbers() that returns an array of 6 random SuperLotto lottery numbers. The first 5 numbers must be from the range 1 to 47 The 6th number (the MEGA) must be from 1 to 27. Create a method called printTicket() that takes an integer array as an parameter it will loop through the integer array and print out the data Display the...

  • C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with...

    C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with each element representing its column and row value, starting from 1. So the element at the first column and the first row will be 11. If either length is out of the range, simply return a null. For exmaple, if colLength = 5 and rowLength = 4, you will see: 11 12 13 14 15 21 22 23 24 25 31 32 33 34...

  • C# Code please with picture of code.Thanks! 1. Create a Main method, and create a 2D...

    C# Code please with picture of code.Thanks! 1. Create a Main method, and create a 2D integer array called data, with a size of five (5) by five (5). Ask the user to input the values for this array (Scanner’s nextInt) 2.Create a method called LongestPositiveSeries, that takes in a 2D array and finds the length of the longest continuous series of positive numbers in it. For example, if we had an array like this: 0 1 2 3 4...

  • 1. Create a new class called ReversibleArray. 2. In the class header, add the code <T>...

    1. Create a new class called ReversibleArray. 2. In the class header, add the code <T> immediately to the right of the class name. 3. Give this class two private instance variables: T[] array and int count 4. Create a constructor which takes in one parameter of type T[] and assign that parameter's value into this.array. Set count as the length of the array. 5. Add a toString() method that outputs the array values in the format: elem0, elem1, elem2,...

  • write a Java console application that Create a text file called Data.txt. Within the file, use...

    write a Java console application that Create a text file called Data.txt. Within the file, use the first row for the name and data title, and use the second row for column headers. Within the columns, insure that the first column is a label column and other columns contain numeric data. In your application, read file Data.txt into parallel arrays, one for each column in the file. Create method printArrays to print the header row(s) and the (unsorted) data in...

  • For this assignment you are going to write code for the following ONE class called: Print_n_numbers...

    For this assignment you are going to write code for the following ONE class called: Print_n_numbers Here are the specifications for the class: Make sure the class Print_n_numbers has a default constructor, i.e. it is possible to create an object of the class by executing: new Print_n_numbers() The class has only one method: print. Specs for the method: name: print arguments: one int, called n. returns: nothing what it does: it prints the numbers 1, 2, 3 ... n if...

  • Introduction to Engineering I Spring 2019 MATLAB Homework Assignment 1 a) Create a matrix called ...

    help wanted? Introduction to Engineering I Spring 2019 MATLAB Homework Assignment 1 a) Create a matrix called d from the third column of matrix a. (Hint, typing d 22: 5: 821 b) Combine matrix b and matrix d to create matrix e, a two-dimensional matrix with three rows c) Combine matrix b and matrix d to create matrix f, a one-dimensional matrix with six rows and d) Create matrix g from matrix a and the first three element of matrix...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT