WRITE 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.
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')])

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
WRITE CODE FOR NEXT 10 QUESTIONS USING THE IMAGE ABOVE !! 1.Create a matrix (called scores)...
Please help me write the following code in java the instructions are here- Using the following table: Time (seconds) Athlete name Nationality Date Location 9.58 Usain Bolt Jamaica 16 August 2009 Berlin 9.69 Tyson Gray USA 20 September 2009 Shanghai 9.69 Yohan Blake Jamaica 23 August 2012 Lausanne 9.72 Asafa Powell Jamaica 2 September 2008 Lausanne 9.78 Nesta Carter Jamaica 29 August 2010 Rieti 9.79 Maurice Greene USA 16 June 1999 Athens 9.79 Justin Gatlin USA 5 August 2012 London...
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. 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++...
In Java, declare a 2-dim array called matrix which holds up to 35 values (of type int) 5 rows and 7 columns each. Using sub-array processing and modularity, create methods to do the following: 1. Fill the array matrix with random numbers between 1-100 2. Compute the cumulative sum of the array matrix 3. Using column-wise processing compute, and print the cumulative sum of all the elements in each column 4. Compute the min value of the array matrix 5....
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 ...
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...
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# 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> 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,...
I just need the code in c++ by using array and random number generation Write a function called rollDice. This function emulates rolling two 6-sided dice Choose two random numbers between 1 and 6 They should be random enough (pseudo-radom), not the same random number every time the function is run Add the numbers together and return the sum Note: it is not sufficient to merely randomly choose a number between 2 and 12, can you see why? Write a...