Question

I have few minutes left, please help write R code to create a matrix (3 rows...

I have few minutes left, please help

write R code to create a matrix (3 rows and 4 columns) that looks like this:

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

syntax for creating a matrix in R is :

matrix(data, nrow, ncol, byrow, dimnames)

data is the input vector which becomes the data elements of the matrix.

nrow is the number of rows to be created.

ncol is the number of columns to be created.

byrow is a logical clue. If TRUE then the input vector elements are arranged by row.

dimname is the names assigned to the rows and columns.

Program:

rownames = c('', '', '')
colnames = c('', '', '', '')
M <- matrix(c(10, 10, 10, -10, -10, -10, 10, 10, 10, -10, -10, -10), nrow = 3, ncol= 4, byrow = FALSE, dimnames = list(rownames, colnames))
print(M)
. Execute > Share main.r STDIN 1 # Elements are arranged sequentially by row. 2 rownames = c(,, ) 3 colnames = c,. 4 MI.li Result $Rscript main.r 10 -10 10 -10 10 -10 10 -10 10 -10 10 -10

Add a comment
Know the answer?
Add Answer to:
I have few minutes left, please help write R code to create a matrix (3 rows...
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
  • Please help me in thsi question i have only 30 minutes this is python Question Two....

    Please help me in thsi question i have only 30 minutes this is python Question Two. 25 points. Write the missing function such that when the following code executes: import numpy as np # Assume the user enters a valid integer #Assume the user enters o valid integer rows - intinput("Enter number of rows (1-10 ")) inti nputl Enter number of columns 1-10 : columns matrix np.random.randint(1, 11, rows columns).reshapelrows, columns) print"Matrix Shape:" matrix.shape, "MatrixIn". matrix) result sum _border(matrix) print/"The...

  • Write a code that gets the quiz grades of a class. A matrix with n rows...

    Write a code that gets the quiz grades of a class. A matrix with n rows and m columns where n stands for number of students and m is the number of quizzes. Let’s call the matrix A. Then, your code drops the lowest grade of each student and remove it from the matrix. Also, it finds the average grade for the quizzes for each student and add a new column to the end the matrix. in matlab please

  • please answer both questions thank you! How many rows and columns must a matrix A have...

    please answer both questions thank you! How many rows and columns must a matrix A have in order to define a mapping from R into R by the rule T(x) Ax? Choose the correct answer below OA. The matrix A must have 7 rows and 7 columns. O B. The matrix A must have 9 rows and 7 columns OC. The matrix A must have 9 rows and 9 columns O D. The matrix A must have 7 rows and...

  • Problem 1 Write your code in the file MatrixOps.java. . Consider the following definitions from matrix...

    Problem 1 Write your code in the file MatrixOps.java. . Consider the following definitions from matrix algebra: A vector is a one-dimensional set of numbers, such as [42 9 20]. The dot product of two equal-length vectors A and B is computed by multiplying the first entry of A by the first entry of B, the second entry of A by the second entry of B, etc., and then summing these products. For example, the dot product of [42 9...

  • Write in C code What to do Write a function with the following signature: float* matrix...

    Write in C code What to do Write a function with the following signature: float* matrix multiplication(float* left, float* right, int rows, int shared, int columns); The first two arguments are two pointers to the beginning of two matrices with the dimensions (rows,shared) and (shared, columns) correspondingly. The remaining arguments specify these dimensions. The return value will return a pointer to the very beginning of the result matrix. That said, you need to provide the space for the result matrix...

  • Create a matrix with 3 rows and 4 columns. Every element in the first row should...

    Create a matrix with 3 rows and 4 columns. Every element in the first row should be 0, every element in the second row should be 1, and every element in the third row should be 2. But don’t just type out all the numbers. Use some ingenuity. Display the matrix using MATLAB.

  • A matrix A has 3 rows and 4 columns: a11 a12 a13 a14  a21 a22...

    A matrix A has 3 rows and 4 columns: a11 a12 a13 a14  a21 a22 a23 a24 a31 a32 a33 a34 The 12 entries in the matrix are to be stored in row major form in locations 7609 to 7620 in a computer’s memory. This means that the entires in the first row (reading left to right) are stored first, then entries in the second row, and finally entries in the third row. Which location with a22 be stored...

  • Please help with the below. Thank you! Please use R Console: I have to create a...

    Please help with the below. Thank you! Please use R Console: I have to create a command in R console so that below all has 3 bins. Below is the data: 107 194 146 40 8 4 1 Please show the command so that all have minimum 3 bins. The command should be something like the below: newbreaks=c(breaks[1], breaks[i:j],breaks[n])

  • how can i solve the system of these magic matrices using matlab software ? Exercice 3. A magic matrix is a square matrix with integer entries in which all the rows, columns and the two diagona...

    how can i solve the system of these magic matrices using matlab software ? Exercice 3. A magic matrix is a square matrix with integer entries in which all the rows, columns and the two diagonals have the same sum. For example, A- 3 5 7 4 9 2 Complete the following magic matrices 17? ?? 3 ? 2 ? 2? ? Do the following steps in each case: 1. Write the system of equations and put it under the...

  • cope the code please thanks Write a MATLAB code to obtain the following. Keep your code...

    cope the code please thanks Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Generate a matrix "A" as follow. A= 16 6 8 2 10 18 12 14 4 I. II. Divide the matrix A by 2 and store the result in a matrix B. Combine matrices A & B to obtain the following matrix C. Also...

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