Last answered:

12 Nov 2022

Posted on:

06 Nov 2022

0

Resolved: Trouble separating by age and sex

My code was following the course:

tb <- read.csv("tb.csv")
tb <- as.tibble(tb)
tb

tb.gathered <- tb %>% gather(m.014:f.65, key = "column", value = "cases", na.rm = T) %>% arrange(country)
tb.gathered
tb.separated <- tb.gathered %>% separate(column, into = c("sex", "age"), sep=".")



And here I get the next error message:

Warning message:
Expected 2 pieces. Additional pieces discarded in 2273 rows [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...]. 

So, when I call tb, I get the columns "sex" and "age" empty.

2 answers ( 1 marked as helpful)
Posted on:

11 Nov 2022

0

you need to remove sep="." from your code. then the code will run without warning message. I hope it will work.

Posted on:

12 Nov 2022

0

It did, thank you!

Submit an answer