How to make my first column in excel the first column of my data frame in r when importing it?

Hi!data from the example image
Species <- c("Prionospio", "Magelona", "M.schu", "N.isa", "Cirratulidae", "O.tegu", "Anthozoa" )
v.small <- c(0, 3, 3, 2, 0, 0, 0)
small <- c(3, 0, 0, 1, 3, 0, 0)

I would suggest to look at openxlsx2 package with wb_load() package where one can specify coloumn and row to start importing and even range_name.


Species is your first column; the numbers on the left are not a column, they are the view you are looking at showing some form of implicit or explicit rowname.

I understand, I want to move the Species column to the first column on the left that has all numbers.

you cant. but it doesnt matter that you cant.
if you want to calculate with this; then you can rely on the fact the your Species column is there and is the first column.
if you want to publish this, then you need to understand what format you want to publish it to (example formats HTML/WordDoc/Latex) and then there are various ways of controlling what gets printed.

I urge you not to get distracted by the fact that the viewer you are using is listing the row numbers for you; its a thing about your viewer.

Edit : Think about how in excel itself there is a header or virtual row with alphabetic labels A,B,C... etc. and a first virtual column 1,2,3,4 showing the row number, these are not editable cells in excel either


If you really wanted to, you could do this:

df <- data.frame(v.small, small, row.names = Species)


But as the others have said, there is no reason to.

1 Like