Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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 (107k 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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...