0
R matrices Code Coach pls help!
Here this one is really hard to me , i tried to get it to work but some or the other gets wrong and I can't fix it pls help me solve Question: Matrix operations are often used in data manipulation and processing. To solve this task, you need to define a matrix with the given number of rows and fill it with the numbers 1 to 10. After that, output the transpose of the resulting matrix. Sample Input 3 Sample Output [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 [4,] 10 1 2 My code: rows <- readLines('stdin') rows <- as.integer(rows[1]) m <- matrix(c(1:10),nrow = rows) print(t(m))
7 Antworten
+ 2
rows <- readLines('stdin')
rows <- as.integer(rows[1])
m <- matrix(c(1:10),nrow = rows)
print(t(m))
+ 1
Do you already have some code?
+ 1
data <- c(1, 2, 3, 4, 5, 6, 7, 8, 9,10)
A <- matrix(data, nrow = 3, ncol = 4)
A_T <- t(A)
print("transpose of A")
print(A_T)
+ 1
I had but i dint save the code
+ 1
🙂👍
+ 1
Finnally I got my to copy paste my code it was not working for some reason , here is my code
+ 1
Does it work now? My code looks almost the same, only the third line is different:
y <- matrix(1:10, nrow = rows,)