Antex
Antex

Reputation: 1454

how to split a column based on gender

Can we split a column using tidyr? Trying to avoid having to use a function.

From this

var1
Men.2001
Men.2002
Women.2001
Women.2002

To this

Gender   Year
Men      2001 
Men      2002
Women    2001
Women    2002

Upvotes: 0

Views: 649

Answers (1)

akrun
akrun

Reputation: 887213

We can use separate

library(tidyr)
separate(df1, var1, into=c('Gender', 'Year'))

Upvotes: 3

Related Questions