I have a dataset with two values in a cell/column per row:
Gene Count
ACE 1,2
BRCA 3,7
HER2 100,300
I am trying to sum the numbers in each row of the count column to output:
Gene Count
ACE 3
BRCA 10
HER2 400
I've been trying to build something to get the numeric values but I don't know how to then specify the addition of values per row:
getnum = function(col) str_extract_all(col,"[0-9\\.-]+") %>%
lapply(.,function(x)as.numeric(x) ) %>%
unlist()
Any help or suggestions on what to use would be appreciated.
Input data:
structure(list(Gene = c("ACE", "BRCA", "HER2"), Count = c(3L,
10L, 400L)), row.names = c(NA, -3L), class = c("data.table",
"data.frame"))