How to create a matrix from an excel spreadsheet

Hello! I am new to R.
I am trying to create a matrix from an excel spreadsheet. It has more than one thousand rows and columns. I used "read_excel" and, right now, I am at a loss of what to do next.
Does anyone know how to proceed?

And what happened?

If you did something like:

aa  <-  read_excel("myfile.xlsx")

what happens if you do

print(aa)

If possible we need to see your code and some sample data from the Excel file.


Have a look at
https://forum.posit.co/t/faq-how-to-do-a-minimal-reproducible-example-reprex-for-beginners/23061.

Thank you for your reply!
Well, I learned how to create a matrix starting from vectors. Then I thought about making vectors in this case too. However, since the spreadsheet has so many rows and columns, I didn't believe it would solve my problem.

This is indeed basically what I did and, if I print it, R will only show the df.
I don't know if you can help me with this, but I thank you once again! :smiley:

You can convert the data frame to a matrix with as.matrix()

aa <- as.matrix(aa)

A matrix can only contain one data type, so if any of your data are character, the entire matrix will be characters.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.