I have the below data. I want to convert these numbers to numeric and I want to do the same for the mixed cells too. In the case of "c(3,1)" I want those values summed together (answer should be 4) so I essentially want to remove all non numbers and sum them together (so in case of "1,2" it should become 3. Anyone know of an easy way to achieve this?
df <- data.frame(
a = c("1","2","c(3,1)","1:3", "2:1"),
b = c("2", "c(2,1", "1,2","4", "2")
)
It does. I found a much better way to work with my data. In terms of solving it for the data provided here, this approach seems work decently well. One would still just have to wrap this and iterate over each cell but that is not so bad.