This is a test version of Biostars. For the public version, visit https://www.biostars.org.
write.xlsx with row.names=TRUE giving error "unused argument (row.names=TRUE)

Dear all,

This is driving me crazy, maybe someone has an idea.

I simply want to print the rows of my dataframe with

write_xlsx(dd, "Z:/dd.xlsx",row.names=TRUE)

But this error keeps coming:

"unused argument (row.names = TRUE)"

Why is it not working?

It works if I remove "rownames=TRUE", but then it doesnt print the rownames.

Thank you so much! Bine

r write.xlsx row.names

1 answer

It appears write_xlsx doesn't have a parameter row.names. Why don't you just add a column for row names to the dataframe dd before writing it? Like:

dd$row_names <- rownames(dd) 
dd <- dd[, c(ncol(dd), 1:(ncol(dd)-1))] # Make row_names first column

Thanks so much! It is working!! :) :) You saved my morning :)

Log in to answer this question.