Being honest, I guess there's a simple way to do this but I really can't figure out what to do. Here is the problem:
Suppose we have this data:
tibble(
Name = c("James", "James", "James", "Ana", "Ana"),
Fruits = c("Apple", "Orange", "Watermelon", "Grapes", "Apple")
)
#> OUTPUT
#> A tibble: 5 x 2
#> Name Fruits
#> <chr> <chr>
#>1 James Apple
#>2 James Orange
#>3 James Watermelon
#>4 Ana Grapes
#>5 Ana Apple
And this is the second data:
tibble(
Market_Foods = c("Apple", "Orange", "Watermelon", "Grapes", "Peach", "Avocado")
)
#> OUTPUT
# A tibble: 6 x 1
#> Market_Foods
#> <chr>
#>1 Apple
#>2 Orange
#>3 Watermelon
#>4 Grapes
#>5 Peach
#>6 Avocado
What I want to do is to do some kind of join where I can list whether James or Ana have any fruits from the second data.....Something like this:
#> A tibble: 12 x 3
#> Name Has Does_not_have
#> <chr> <chr> <chr>
#> 1 James Apple NA
#> 2 James Orange NA
#> 3 James Watermelon NA
#> 4 James NA Grapes
#> 5 James NA Peach
#> 6 James NA Avocado
#> 7 Ana Grapes NA
#> 8 Ana Apple NA
#> 9 Ana NA Orange
#>10 Ana NA Watermelon
#>11 Ana NA Peach
#>12 Ana NA Avocado
Or maybe it is better to have it like this:
#> A tibble: 6 x 3
#> Name Has_or_Not Fruits
#> <chr> <chr> <chr>
#>1 James Has Apple
#>2 James Has Orange
#>3 James Not Grapes
#>4 Ana Not Orange
#>5 Ana Has Grapes
#>6 Ana Not Apple
#>..... ..... ......
#>..... ..... ......
I did some inner joins with transmute but no luck
Do you have any idea of how to solve this?
Thanks in advance!