0

I am using read.xlsx() function to read a xlsx file, with colNames = FALSE, rowNames = TRUE arguments, everything was fine, but after adding a line of variable, it pops up error saying Error in ".rowNamesDF<-"(x, value = value) : missing values in 'row.names' are not allowed

When I check the problem byView() and using rowNames = FALSE, I found that the last row was introduced by a NA variable. However, since in the manual of read.xlsx() it doesn't say how to define a range, and I can't do like read.xlsx()[1:ncol(),] either, so I don't know what to do.

My trials:

  1. I tried to delete the last row in the xlsx file, but R keeps saying missing value is introduced.

  2. I know I could use rowNames = FALSE argument first and remove the last row, and define first row as row.names(), but I don't want to do so because I think there is a better solution.

Negrito
  • 220
  • 1
  • 9
  • 1
    I would recommend checking how you 'added a line of variable'. The problem seems to be there. Alternatively, using 'read.xlsx' you could define 'row' ("A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.") – huan May 20 '19 at 10:37

1 Answers1

0

Can you provide an example of the data contained in your excel file ? So I can try something based on your data, if I understood you want to add a line at the ned of it right ?

Arkning
  • 181
  • 9
  • I finally sorted it out, probably some of the "empty" cells at the bottom contain some strange values whatever, so I decided simply copy paste my data to a new Excel and I'm fine now. But thanks anyway. – Negrito May 24 '19 at 14:27