I'm trying to calculate the row sum for four columns in a dataframe. The dataframe was imported from an ESRI ArcGIS server and when I look at the structure of the columns I want to sum they all are defined as numeric but I still get the error 'x' must be numeric.
library(sf)
library(dplyr)
STTH <- st_read("https://services.arcgis.com/xxxx/ArcGIS/rest/services/service_xxxx/FeatureServer/")
STTH$projectsum <- rowSums(STTH [,19:22], na.rm = TRUE)
My dataframe looks like this for the columns 19:22
| base_ST_funding | base_stlandowner_funding | base__section6 | base_partners |
|---|---|---|---|
| 1200 | NA | 2100 | 800 |
| 1200 | 200 | 3200 | NA |
| 1200 | NA | NA | 210 |
| 1200 | 350 | NA | NA |
And when I call str(STTH) I get this for columns 19:22
$ base_ST_funding : int 2950 NA NA NA 4905 NA 100 NA NA NA ...
$ base_stlandowner_funding : int 3300 NA NA NA 20981 NA NA NA NA NA ...
$ base_section6 : int NA NA NA NA 40364 NA NA NA NA NA ...
$ base_partners : int NA NA NA NA 25000 NA NA NA NA NA ...