Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in R Programming by (50.2k points)
I have fortunately parsed numerics from a character string into a new column, however for instances, when there are several numerics, it created a character string in that specific row. Any Ideas for a summation of this particular case. I have provided an example. Note that I would like to maintain the integrity of the singular numerics.

My prior parsing produced this in row c("40", "8"), how do I make it 48?

1 Answer

0 votes
by (108k points)

Let suppose you have a dataframe called df and a column with name as col, you can execute the following:

df$total <- sapply(df$col, function(x) sum(as.numeric(x)))

If you are interested in R certification then do check out the R programming certification

Browse Categories

...