1
I am using a database with information about the Olympics(https://www.kaggle.com/heesoo37/120-years-of-olympic-history-athletes-and-results) and I want to analyze the data on the Olympic sports in which Brazil was medalist. I used the Summarize() function to get a column with number of medals per sport.
but when I go to sum up this column I get the error "Error: object 'sum(total2)' not found".
teste <- na.omit(subset(df1, select = c(Medal, Team, Sport, Event)))
teste <- teste %>% rename(pf = Sport)
teste <- teste %>% rename(pv = Medal)
data <- teste %>% filter(Team=='Brazil') %>%
group_by(pv, pf) %>% distinct(Event) %>%
summarize(total2 = n())
sum(total2)
I’ve tried the function colSum but returns the same error.
Taking advantage of the post, would it be possible to create a pie Chart with the medalist sports? I tried to do using the ggplot2 but I couldn’t.


sum(data$total2); 2) Why Chart pie? Bar charts are considered better. 3) Can you please, edit the question with the departure ofdput(data)or, if the base is too large,dput(head(data, 20))? Or where to find the original data.– Rui Barradas
Welcome to the Sopt. This is a website to answer practical programming questions, it is important to provide in addition to your code a sample of the data you are using. Read more about this in this topic Help Center. See also this post for details on how to make a minimal example in R.
– Carlos Eduardo Lagosta