rowSums() error: 'x' must be numeric

Viewed 4488

I am trying to sum each row of the incomeData table. Here's my data: enter image description here

Here's my code

incomeData <- read.csv("~/xxxx/xxxx/IncomeData279332c31ddd.csv", 
header=FALSE)
incomeData <- incomeData[-1,] #remove the first row in the incomeData
incomeData$district_sampleSum <- rowSums(incomeData)
sapply(incomeData, typeof) 

I kept getting an error from this line:

> incomeData$district_sampleSum <- rowSums(incomeData)
Error in rowSums(incomeData) : 'x' must be numeric

I tried to debug by trying:

sapply(incomeData, typeof) 

It shows all columns are integers and doubles. So I am not sure why R would complain x to be numeric.

enter image description here

0 Answers
Related