AgusDam87
AgusDam87

Reputation: 97

Create a pivot with 3 variables in R

I have three variables in one dataframe:

Country <- ("ARG","BR","US","ARG","ARG","BR","CH")
Education_level <- ("HIGH","COLLEGE","KINDER","KINDER","COLLEGE")
Indicator <- (1,1,1,0,1,0,1,0,0,0,1,1,0,1,0,1,1)

I Need to create a pivot or some groupby counting or summarising the values of "Indicator" grouped by Country and Education_level. How can I do that?

Upvotes: 1

Views: 114

Answers (1)

akrun
akrun

Reputation: 886938

We can use xtabs from base R

xtabs(Indicator ~ Country + Education_level)

Upvotes: 1

Related Questions