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

dplyr
#1

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))

0 Likes

#2

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

#3

Thanks, for pointing out my error!

0 Likes

#4

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:

0 Likes

closed #5

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.

0 Likes