Hello, I am trying to change my data from long to wide. I have an example of what it could look like
Instead, I want to see it as a wide and I want to create a new column T/F column to see if they have ever traveled to a certain continent and I want to make sure I can count how many Ts and Fs, like this:
I tried to do something like with group_by and mutate but I was definitely doing something wrong.
A = original long wide dataset
A$Asia = asia %>%
group_by(ID) %>%
mutate(Asia = {if(Continent='Asia') T else F})
What is the best way to do this?
~~ Reproducible example ~~
data.frame(
stringsAsFactors = FALSE,
ID = c(1L,1L,1L,2L,2L,2L,2L,3L,3L,4L,4L,
4L,4L,4L),
Continent = c("Asia","Asia","Africa","South America",
"Asia","Africa","Europe",
"North America","Europe","Africa","South America",
"Europe","Africa","Asia")
)