Need help creating an object "svar" using group_by, and summarize

I am getting an error object "avg" not found.... what am I missing?

svar <- polls %>% select(pollster, avg, s) %>%
group_by(pollster) %>%
summarize(avg=mean(spread), s=sd(spread))

This is happening because you are trying to select avg before you create this variable in the summarize command, try dropping the redundant select command.

svar <- polls %>%
  group_by(pollster) %>%
  summarize(avg=mean(spread), s=sd(spread))
1 Like

Thanks, for pointing out my error!

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.