I have a large data frame with columns that are a character string of numbers such as \"1, 2, 3, 4\". I wish to add a new column that is the average of these numbers. I have
You could use sapply to loop through the list returned by strsplit, handling each of the list elements:
sapply
strsplit
sapply(strsplit((df$a), split=", "), function(x) mean(as.numeric(x))) # [1] 2.5 5.0 7.5